GIT merge into master howto

git fetch origin
git checkout --track -b master origin/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
git pull --rebase origin master
# 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 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
# only if everything is ok and you looked at the log
# push the changes on the local "master" branch to the repository "master" branch
git push origin master:master 
git reset --hard ORIG_HEAD  # WARNING: all local changes to the current branch will be lost

GIT commit from local branch into master

If all you want to do is commit some changes you have in a local branch (called "my_local_branch" from now on), then you could use:

# change to my local branch
git checkout my_local_branch
# make sure we have the latest version of the "origin" branches
git fetch origin
# rebase "my_local_branch" to the current origin/master
git rebase 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:master

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/master version
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:master