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.

I have been developing a new feature on a new branch, on the side I have committed quite a few changes on my master branch.

I would like to know if it's possible to merge the master branch in my new branch to keep it up to date so I wont have too many merge conflict when my new feature is finished?

share|improve this question
    
Have you tried git-merge ? Help here. –  karatedog Dec 20 '10 at 15:21
add comment

1 Answer

up vote 31 down vote accepted

You can either git merge master or git rebase master, in this case i would prefer git rebase.

Edit: Because git rebase makes it as if the changes on the feature branch were made on top of the changes on the master branch, and it makes the version graph simpler.

Edit again: git rebase is only suitable when the branch hasn't been distributed, or there will be confusion and extra work downstream.

share|improve this answer
    
You should explain why you prefer rebase and what the difference is. Rebase creates a linear history - this might not fit this question. –  Andreas Rehm Dec 20 '10 at 18:47
    
Ok if I understand it well: I have to checkout the master branch if the newfeature is not finished yet and a rebase if it's finished? –  mnml Dec 20 '10 at 22:28
    
No, with the feature branch checked out, do git rebase master, and it will "rebase" the changes in the feature branch so that they are "based" on the changes in the master branch. If the changes in the master branch conflict with the changes in the feature branch, git will ask you to resolve them and continue, skip them, or abort. If you feel unsure you can checkout a test branch to try it on with git checkout -b test-feature feature (assuming your feature branch is named "feature"). –  Christoffer Hammarström Dec 21 '10 at 6:40
    
I have done my rebase but now when I pull from another computer I can't see my branch anymore: I have done git checkout newfeature / git rebase master –  mnml Dec 21 '10 at 14:32
2  
What do you mean "can't see my branch anymore"? Anyway, git rebase should only be used if the branch hasn't been distributed, which i assumed was the case since you said it was a new branch, sorry about that. See Recovering from upstream rebase in the docs i linked to. You'll have to use git merge instead. And you can use git reflog to find your previous feature branch head if you want to get it back. –  Christoffer Hammarström Dec 21 '10 at 15:40
show 1 more 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.