Switch branch names in git

In addition to the other comments, you may find the -m (move) switch to git-branch helpful. You could rename your old master to something else, then rename your new branch to master: git branch -m master crap_work git branch -m previous_master master

View differences of branches with meld?

Short & sweet: git config –global diff.tool meld This configures Git to use meld as the diff tool. (You don’t need to specify the command line arguments, support for meld is built into Git.) Then, if you want a graphical diff instead of a textual one, you simply invoke git difftool instead of git diff … Read more

Mercurial: Can I rename a branch?

Update to the stiging branch and create a new branch off of it. Then close the old branch. In summary: hg update stiging hg branch staging hg commit -m”Changing stiging branch to staging.” hg update stiging hg commit –close-branch -m”This was a typo; use staging instead.” hg push –new-branch

Git: Merge a Remote branch locally

You can reference those remote tracking branches ~(listed with git branch -r) with the name of their remote. You need to fetch the remote branch: git fetch origin aRemoteBranch If you want to merge one of those remote branches on your local branch: git checkout aLocalBranch git merge origin/aRemoteBranch Note 1: For a large repo … Read more

Renaming a branch in GitHub

As mentioned, delete the old one on GitHub and re-push, though the commands used are a bit more verbose than necessary: git push origin :name_of_the_old_branch_on_github git push origin new_name_of_the_branch_that_is_local Dissecting the commands a bit, the git push command is essentially: git push <remote> <local_branch>:<remote_branch> So doing a push with no local_branch specified essentially means “take … Read more

What to do with branch after merge

After the merge, it’s safe to delete the branch: git branch -d branch1 Additionally, git will warn you (and refuse to delete the branch) if it thinks you didn’t fully merge it yet. If you forcefully delete a branch (with git branch -D) which is not completely merged yet, you have to do some tricks … Read more