Tue Feb 22 10:09:16 EST 2011
Git and rebase
I want to change the order of patches.
remotes/origin/master - A - B - C - master
remotes/origin/master - C - A - B - master
How to go about that?
The simplest way I see is to:
- rename the current master branch to 'dev'
- set master to remotes/origin/master
- cherry pick on top
This says that: "When it comes to a range of commits,
cherry-picking is not practical."
I'm going to try the cherry pick first.
git branch tom # tag current branch
git checkout master # switch to master (already on)
git reset remotes/origin/master # reset master to remote
git reset --hard HEAD # discard local changes (git reset leaves uncommitted patch on top of new base)
After this you can switch between branches "git checkout tom" and "git
checkout master". To pull in changes from the other branch, simply do:
git cherry-pick <id1> <id2> ...
A simple way to do this is to open up gitk on the other dev branch,
then switch to master branch on the command line and copy-paste the
To flatten patches into a single patch, do this:
git rebase --interactive <id1>
with <id1> the base revision to squash. Hmm.. That didn't really do
anything. I get the following reply which lets me edit a commit
message in emacs, but my master branch still looks the same:
tom@zoo:~/priv/git-private/ecos_trailer$ git rebase --interactive 9e5bf0e6a0dc6a08e20fcf2250244fc07de57191
Waiting for Emacs...
Successfully rebased and updated refs/heads/master.
Maybe the commit message has some commands in it? That might be the
case. Anyways, I think I also found how to just change commit
Let's use the following: