Reputation: 13367
I have a local branch I'm working on that is a copy of master, called mybranch. I have changes to that branch that I want to merge into master. However, there have been updates to master that I need to incorporate into mybranch before I eventually merge my branch back into master.
I'd like to accomplish with a rebase and had somebody help me the first time but didn't really make sense. I tried the following but I can remember say files that are different in mybranch and master highlighted in my intellij IDE as read with diffs in the file itself marked with >>>>HEAD, ETC,. so I could update to the correct changes but I'm not seeing that.
This is what I have tried so far:
$ git checkout master
$ git pull // get latest from master
$ git checkout mybranch
$ git rebase master // get masters updates and integrate them with mine
At this point not sure where I'm at...I just want my local branch updated with masters changes (and there should be conflicts which I hope to resolve then push to my branch then push everything back to master).
Upvotes: 0
Views: 3059
Reputation: 351
This is a pretty common workflow you are describing. Here is a link to a more detailed description.
Once you execute 'git rebase master'
you should have the latest changes from master in your current branch (you may or may not experience merge conflicts). If there are conflicts git will suspend the rebase and prompt you to resolve them, then execute 'git add <file(s)>
' before resuming the rebase with 'git rebase --continue
'.
While it's beyond the scope of you question I do recommend you check out the link or search around for information on interactive rebases. It's used to keep your commit history very clean and organized.
Upvotes: 2
Reputation: 1476
The above took the changes you had in mybranch above "old master" and applied them on top of "refreshed master" if you want to update master with your changes you are simply missing:
git checkout master
git rebase mybranch
which will fast forward master to the HEAD of your new (rebased on master) mybranch. Now master and mybranch should refer to the same SHA1 which are childs of origin/master. At this point, had you started to work on master after the updates from git pull, you would be in that same spot in the history tree.
git push
should take care of breaking the daily build ;)
Upvotes: 1