GIT push into master howto

This howto assumes you did some local changes into your local master branch, you have commited them and now you want to publish them in the public repository. It assumes that you start in your local master branch (git checkout master). For the commit guidelines see GIT Commit Guidelines and for the repository layout Guide for GIT SIP-ROUTER Repository.

If you want to push some changes you did in some other local branch, just replace master:master in git push origin master:master with git push origin HEAD:master.

$ git fetch origin; git log origin/master..HEAD
# alternatively you could try git whatchanged origin/master..HEAD
# instead of git log and/or add --graph --color to git log / git whatchanged
$ git push origin master:master
To ssh://git.sip-router.org/sip-router
 ! [rejected]        master -> master (non-fast forward)
error: failed to push some refs to 'ssh://git.sip-router.org/sip-router'

it means that your local branch version is not anymore up-to-date with what's on the public repository. In this case do a rebase (3):

$ git fetch
$ git pull --ff --rebase origin master
remote: Counting objects: 370, done.
remote: Compressing objects: 100% (125/125), done.
remote: Total 264 (delta 235), reused 140 (delta 139)
Receiving objects: 100% (264/264), 35.32 KiB, done.
Resolving deltas: 100% (235/235), completed with 101 local objects.
From ssh://git.sip-router.org/sip-router
 * branch            master     -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
Applying: perl(k): fixed makefile

everything went ok and you only need to retry the push:

$ git push origin master:master
Counting objects: 9, done.
Delta compression using 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 515 bytes, done.
Total 5 (delta 4), reused 0 (delta 0)
Mailing notify to sr-dev@lists.sip-router.org
commit_notice master, bd3e028334907c3622e1537d337a9938ed355060
To ssh://git.sip-router.org/sip-router
   4568924..bd3e028  master -> master

NOTE: you could update your branch (3) also with git pull –ff (no –rebase), but then a confusing merge commit message will be recorded (e.g.: "Merge branch 'master' of ssh://git.sip-router.org/sip-router"), so it's highly recommended to use the –rebase method above.

$ git pull --rebase origin master
refusing to pull with rebase: your working tree is not up-to-date

it means you have some uncomitted local changes. Commit them (git add … && git commit) or save them for latter use/review (git stash save "local changes") or discard them (git checkout file_with_changes or git reset –hard HEAD) and then try again.