Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
git:merge-into-master [2009/04/17 14:57]
andrei adding shorter git pull --rebase version
git:merge-into-master [2012/12/11 16:50] (current)
oej old revision restored
Line 3: Line 3:
   * if you don't have a local **master** branch tracking **origin/master** (git branch|grep master is empty)   * if you don't have a local **master** branch tracking **origin/master** (git branch|grep master is empty)
 <code> <code>
 +git fetch origin
 git checkout --track -b master origin/master git checkout --track -b master origin/master
 </code> </code>
Line 10: Line 11:
 <code> <code>
 git checkout master git checkout master
 +# make sure we have the up-to-date "origin" branches
 +git fetch origin
 # make sure the local "master" branch is up-to-date # make sure the local "master" branch is up-to-date
-git pull --ff origin master+git pull --rebase origin master 
 +</code> 
 + 
 +  * do the actual merge 
 + 
 +<code>
 # merge the branch into the local "master" branch # merge the branch into the local "master" branch
 git merge --log --no-ff origin/branch_to_merge # for older git version, make sure merge.summary is true and skip --log git merge --log --no-ff origin/branch_to_merge # for older git version, make sure merge.summary is true and skip --log
 git log -1 # make sure you see a correct merge message (with summary), if not abort git log -1 # make sure you see a correct merge message (with summary), if not abort
 +git log ORIG_HEAD.. # make sure the commits shown are what you wanted to merge, if not abort
 gitk # optional, look if the commit tree looks ok gitk # optional, look if the commit tree looks ok
 # only if everything is ok and you looked at the log # only if everything is ok and you looked at the log
Line 21: Line 30:
 </code> </code>
  
-  * if you did something wrong and pushedand it cannot be easily corrected by a git revert, send an email to sr-dev@lists.sip-router.org asking to revert master to the previous state (this should be avoided in general since it would cause extra work for all people who fetched or pulled master in the meantime)+  * if you did something wrong and pushed and it cannot be easily corrected by a git revert, send an email to sr-dev@lists.sip-router.org asking to revert master to the previous state (this should be avoided in general since it would cause extra work for all people who fetched or pulled master in the meantime)
  
-  * if you need to abort or undo a merge attemptyou don't have any local changes that you want to keep and you haven't pushed back to origin (if you did, see above), use:+  * if you need to abort or undo a merge attempt and you don't have any local changes that you want to keep and you haven't pushed back to origin (if you did, see above), use:
 <code> <code>
 git reset --hard ORIG_HEAD  # WARNING: all local changes to the current branch will be lost git reset --hard ORIG_HEAD  # WARNING: all local changes to the current branch will be lost
Line 42: Line 51:
 # if everything is ok and you don't have any rebase conflicts, push the  # if everything is ok and you don't have any rebase conflicts, push the 
 # changes to the repository master branch # changes to the repository master branch
-git push --ff origin my_local_branch:master+git push origin my_local_branch:master
 </code> </code>
-Alternatively you could use a shorter version, by replacing the git fetch and git rebase with git pull --rebase:+Alternatively you could use git pull --rebase instead of git rebase:
 <code> <code>
 # change to my local branch # change to my local branch
 git checkout my_local_branch git checkout my_local_branch
 +git fetch origin
 # rebase on the latest origin/master version # rebase on the latest origin/master version
 git pull --rebase --ff origin master git pull --rebase --ff origin master
 # if everything is ok and you don't have any rebase conflicts, push the  # if everything is ok and you don't have any rebase conflicts, push the 
 # changes to the repository master branch # changes to the repository master branch
-git push --ff origin my_local_branch:master+git push origin my_local_branch:master
 </code> </code>

Navigation

Wiki

Other

QR Code
QR Code git:merge-into-master (generated for current page)