I'm using git (in fact, msysgit) 1.6.4 on Windows. Most of the time I'm doing work in some feature branches. Every now and then, I want to hop back to master to cherry-pick one particular commit I did in my feature branch - usually because it's a useful bugfix which makes sense even without the feature. My workflow is like this - if this is unnecessarily complicated, please tell me :-) :
git checkout -b mycoolfeaturebranch // hack away, implementing a feature and one bugfix (while I'm at it) git add file_with_bugfix.cpp git commit -m "Fixed bug 12345 // commit the bugfix git checkout master // hop over to master git cherry-pick // bring the bugfix into master
At this point, I usually want to hop back to my feature branch to continue work on the feature. Unfortunately, my branch names tend to become a little long (like, 'mycoolfeaturebranch') and I don't have git branch name tab completion on Windows.
Is there maybe something like cd -
on Unix shells (which hops to the previous directory, useful for toggling between two directories)? A git checkout -
would be great. :-)
From $GIT/Documentation/RelNotes-1.6.2.txt:
Did you try it?
Try:
From git rev-parse:
As mentioned by Stefan Näwe in his answer:
Even though the syntax
@{-1}
has been around 1.6.2, it is only since 1.6.2 it is fully effective, as Junio C. Hamano comments back in February 2009 (emphasis mine):(Note: that differs from
@{<n>}
)