My ~/.gitrc looks as follows:
[user] name = yourname email = youremail [color] status = auto diff = auto branch = auto [core] editor = vim [push] default = simple
Whenever switching branches with git checkout branchname, the current changes will be taken over to the new branch. So switching branches is really a matter of seconds.
$ git branch * master $ git branch testing $ git branch * master testing $ git checkout testing $ git branch master * testing $ git remote add testing git@github.com:user/repo.git # for github users $ git commit -m "Initial commit on testing." $ git push testing testing # or 'git push' for later ... $ git checkout master $ git merge --no-ff testing $ git remote rm testing $ git branch -d testing
If you merge accidentally and you want to undo it, just check git log to see which commit is the prior to the merge. Then there are two ways:
$ git reset --hard commit_sha
or
$ git reset --hard HEAD~2 # go back 2 commits
Source: Stack Overflow: "git: undo a merge?"