I'm rather new to github social coding and are having trouble following github guidelines. I'll try to describe what happened and what I'm trying to achieve - hoping that more experienced git wizards can help me figure out the arcade commands needed to get there.
I'd like to get all changes that were merged into upstream/master. Preferrably as their respective commits, not one massive commit of hundreds of files. Because I was doing development on the former upstream/master (dated Mar 29, 2012), I guess would effectively need to "insert" some commits in between the last upstream/master change of Mar 29 and my first commit of Aug 8, and then on top of that add those that happened later. How do I do that?
(I'd also like not to destroy my commits/fork in the process ;-)
git checkout master
git remote add upstream git://github.com/phatboyg/MassTransit.git
git rebase upstream/master
git push
However, it would not let me then do git push
, complaining that my local tip was 10 commits behind the origin (possibly the commits I made on my topic branch and later merged into origin/master?).
It seems that I may have been bitten by recommendations. Eg. perhaps it would be better to create a separate branch, eg. local-master, and treat that as... well, my own master. Then master would be there only for keeping in touch with upstream/master, and I would occasionally rebase origin/master with upstream/master and merge with origin/local-master...
How do you guys manage your forks?
I've been unable to find a way to visualize branch history, what branch was merged with another and when, etc. Github for Windows only shows a flat history for the currently selected branch (sad face here). The website does have some visualizations for the network (here is one for MassTransit), but this feels a lot less informative than say the graphs in TortoiseHg. Am I missing something obvious? Does everyone else just remember what was merged with what and when?
I'm sharing a poor-man's visualization to help explain what happened.
I assume that you will be, or have, set up an origin
remote to your fork, and the same again for upstream
(as described).
I would then do a fetch of the upstream
so that you have all their branches held locally. You can then make the comparisons between the repos and see if there is a common commit at or near the divergence date.
The gitk --all
visualisation is useful here. Don't forget that even if you do a rebase the old commit series is still there so you can give it a name
[EDIT] A wordy description.
Clearly the merge commit is 'getting in the way' so needs to be massaged away so that the repos can be brought in sync again.
temp
branch at your current head, so nothing gets lost.reset
your master branch back to the last common commit between you and upstream.reset
your feature branch to just before the merge.checkout
that merge commit to get the working tree as you expect, thencommit
that fixed work tree on your feature
branch (i.e. no merge).You now have a clean line on master
, a clean but old line on feature
, and any post merge developments on temp
. if Happy, you should be able to force push this to your origin
.
pull
from upstream - it (i.e. master
, etc.) should all fast forward.rebase
those post merge developments from temp
onto feature
(if required).rebase
feature
to the last commit you know well on master (should be relatively easy).rebase
feature
(again) to the latest commit on master, fixing up as you go (combine with the last step if it's easy;-).This should finally give you a clean line of feature development at the head of master, and suitable for pulling upstream without any conflict.
Here are some ideas.
Cherry pick method:
git checkout master
git cherry-pick C2..C4
New branch rebase method:
git checkout upstream/master
git branch new-master
git rebase master
# new-master should now look like what you want, once you confirm this
git branch -m master old-master
git branch -m new-master master
Rebase --onto method (lets you pick which range of commits you want):
git checkout master
git rebase --onto master C2 C4 # puts you into a detached HEAD
git branch new-master
# rename branch as above if it is correct
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With