Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
git:merge-into-master [2008/11/27 15:25] andrei created |
git:merge-into-master [2012/12/11 16:50] (current) oej old revision restored |
||
---|---|---|---|
Line 1: | Line 1: | ||
===== GIT merge into master howto ===== | ===== GIT merge into master howto ===== | ||
- | * if you don\'t have a local **master** branch tracking **origin/ | + | |
< | < | ||
+ | git fetch origin | ||
git checkout --track -b master origin/ | git checkout --track -b master origin/ | ||
</ | </ | ||
* if you already have a local **master** branch tracking **origin/ | * if you already have a local **master** branch tracking **origin/ | ||
+ | |||
< | < | ||
git checkout master | git checkout master | ||
- | git merge --log origin/ | + | # make sure we have the up-to-date " |
+ | git fetch origin | ||
+ | # make sure the local " | ||
+ | git pull --rebase origin master | ||
+ | </ | ||
+ | |||
+ | * do the actual merge | ||
+ | |||
+ | < | ||
+ | # merge the branch into the local " | ||
+ | git merge --log --no-ff | ||
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 | ||
+ | # push the changes on the local " | ||
git push origin master: | git push origin master: | ||
</ | </ | ||
- | * 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 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 attempt, 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: | + | * if you need to abort or undo a merge attempt |
< | < | ||
git reset --hard ORIG_HEAD | git reset --hard ORIG_HEAD | ||
</ | </ | ||
- | * don\'t try to merge the reverse way, e.g.: git checkout my_branch; git merge master; git push origin my_branch: | + | * don't try to merge the reverse way, e.g.: git checkout my_branch; git merge master; git push origin my_branch: |
+ | |||
+ | ===== GIT commit from local branch into master ===== | ||
+ | |||
+ | If all you want to do is commit some changes you have in a local branch (called " | ||
+ | < | ||
+ | # change to my local branch | ||
+ | git checkout my_local_branch | ||
+ | # make sure we have the latest version of the " | ||
+ | git fetch origin | ||
+ | # rebase " | ||
+ | git rebase origin/ | ||
+ | # if everything is ok and you don't have any rebase conflicts, push the | ||
+ | # changes to the repository master branch | ||
+ | git push origin my_local_branch: | ||
+ | </ | ||
+ | Alternatively you could use git pull --rebase instead of git rebase: | ||
+ | < | ||
+ | # change to my local branch | ||
+ | git checkout my_local_branch | ||
+ | git fetch origin | ||
+ | # rebase on the latest origin/ | ||
+ | git pull --rebase --ff origin master | ||
+ | # if everything is ok and you don't have any rebase conflicts, push the | ||
+ | # changes to the repository master branch | ||
+ | git push origin my_local_branch: | ||
+ | </ |