Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

At the university where I work, we use an open source learning management system (Moodle). Over time, we've edited the source code directly to fix bugs we've found and provide custom functionality. I'd like to be able to keep up with the bug fixes via a Git repository while also keeping track of our changes and making sure that our edits are preserved.

I'm a relative Git newbie, but from what I can tell here is our current situation.

     --C----C----C----C----C   < custom
    /
---B-----F-----F-----F-----F-----F-----F--...   < origin

B = the build we installed
C = our changes
F = bug fixes

My question, to make it short, is how to combine the C's and F's together. Merging? Rebasing? Which tree should I merge/rebase into the other?

share|improve this question
    
I'm not saying that the question is not valid for SU, but if you ask it on Stack Overflow you'll find many more Git users, I suspect. –  CarlF Jan 26 '10 at 19:26
    
whitequark's answer works great. I can even see only the changes in the custom branch by running git log --first-parent –  Brandon Tilley Feb 24 '10 at 23:39
    
Note that it is often beneficial for all parties if bug fixes goes upstream, not least for this very reason: keeping a local branch up-to-date can require unnecessary work. When files start to diverge, things get hairy. –  Daniel Andersson Sep 9 '13 at 12:43
add comment

1 Answer

up vote 3 down vote accepted

Merging and rebasing are basically doing the same: making the last commit incorporate changes from both provided branches. But the way them do it is different.

Merging creates a commit that has two specified as parents, and rebasing 'moves' your tree so it's first commit is based (i.e. has one parent) on last commit of other branch (origin in your case). Resulting tree state is identical.

The right thing to do in this case is merge custom branch with origin:

git checkout custom
git merge origin

Rebasing is only useful if you want to send a bunch of patches to maintainer of projects so he doesn't need to adapt them to more recent changes manually.

Rebasing commands would be:

git checkout custom
git rebase origin

Also there is a git-cherry-pick(1) command that can be used to apply an arbitrary commit from any branch as a patch would be.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.