[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
More Git Fu (RE: [csmith-project/csmith] 4ba524: fix a bug...)
[CC'ed Ryan Jackson, the flux-local Git expert, to review my answer.]
Xuejun> I run into this situation a couple of times: I forget, or
Xuejun> didn't realize I need, to pull on master branch before
Xuejun> rebasing+merging the topic branch. Once the merge is done, the
Xuejun> damage is done. Even if I pull on the master again, and redo
Xuejun> rebasing + merging with the topic branch, I lost the capability
Xuejun> of fast forwarding. My questions are:
Easy question first:
Xuejun> 2) even better, is there a way automatically pull on the master
Xuejun> branch whenever somebody else commits while I am working on
Xuejun> a topic branch?
No, not automatically.
Xuejun> 1) if there a way to back out from the 1st rebasing+merging. I
Xuejun> remember I tried stash, but it didn't work.
Let me see if I have this right. You merge a topic branch into your master;
let's assume this is a fast-forward merge. So you get something like this:
origin/master master
| topic
o ----> o ----> o ----> o ----> o ----> o
Then you pull, and git does something like this:
origin/master
(stuff pulled from origin) master
o ----> o ----> O ----> O --------------------> o
| ^
\-----> o ----> o ----> o ----> o ------/
topic
where that last commit is the merge created for you by git.
The way to get out of this, I believe, is: git reset --merge ORIG_HEAD
That should give you this:
origin/master
o ----> o ----> O ----> O
|
\-----> o ----> o ----> o ----> o
topic
master
There's no need to move origin/master back, and you don't really want to
anyway.
At this point you can: git rebase origin/master
yielding:
origin/master
o ----> o ----> O ----> O
|
\-----> o ----> o ----> o ----> o
topic
master
And then: git push
Eric.
--
-------------------------------------------------------------------------------
Eric Eide <eeide@cs.utah.edu> . University of Utah School of Computing
http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX