a misunderstanding of git-checkout

Dec 12th, 2008 | Posted by yajin | Filed under Git

I work in branch master and there are some changes uncommited. Now I have some ideas and want to try it *without* effecting the branch master. I first create a branch test and then checkout to branch test.

kill-bill:/home/root/sdc/qemu/qemu-omap/svn# git branch test
kill-bill:/home/root/sdc/qemu/qemu-omap/svn# git checkout test
Switched to branch "test"
kill-bill:/home/root/sdc/qemu/qemu-omap/svn# git branch
 master
*test

And then I work in branch test and make some changes to source file a.c b.c and etc. At last, I want to return to branch master and abandon the changes in branch test. But the result is not same as what I thought. The files changed in branch test are also changed in branch master!!

Git-checkout DOES NOT save your context and uncommitted changes to somewhere and restore them when you return. If you want git to do so, please use git-switch-branch instead.

No comments yet.