My git-svn work flow is as follows:
Production code goes in master, off which I do my git svn dcommits/rebase. I work on feature/topic branches, and continue to rebase -i to master and merge until I’m ready to bring those into master and subsequently push to svn trunk using dcommit.
I can usually do git checkout - to checkout the previous branch I was on.
For some reason though, when I do git svn rebase, and then try to git checkout to my previous branch, it does not work (it just stays in master). That is, lets say I do:
(master)$ git checkout -b my-feature-branch
I do some work on that branch, then commit
(my-feature-branch)$ git commit -am "Some work"
I then want to bring in the latest changes, and the quickly change back to my branch:
(my-feature-branch)$ git checkout master
(master)$ git svn rebase
This brings in the latest svn trunk changes into master. Now I just want to quickly change back to my topic branch.
(master)$ git checkout -
At this point, the branch checkout stays as master. I’m guessing some sort of operation is popping off the last branch I worked on, but I don’t know about the internals to know this for sure.
So my question is, does anyone know why this is?
When you run
git checkout -,gitconsults the file.git/logs/HEADto find the last branch that you checked out.When you run
git svn rebase, this triggers thecmd_rebasefunction in thegit-svncommand, which in turns calls:This calls
rebase_cmd, which looks like this:So the
gitcommand line built by this chain looks something like:(where
$gs->refnamewould be substitute with a branch name.) And from thegit-rebaseman page:Since the
rebasecommand specifies a branch name,rebaseperforms a checkout, which appends an entry to.git/logs/HEADeven if you are already on that branch. This is why the target ofgit checkout -is not what you expect after runninggit svn rebase.UPDATE I may be wrong about why rebase is performing the checkout, but if you examine
.git/logs/HEADyou can see clearly that rebase is performing (multiple) checkouts. For example, if I have a branchmasterand a branchb1(descended frommaster), and then do:I end up with the following in the the log: