To squash the last 3 commits into one:
git reset --soft HEAD~3
git commit -m "New message for the combined commit"
git push origin +name-of-branch
The plus sign forces the remote branch to accept your rewritten history, otherwise you will end up with divergent branches
git push origin name-of-branch
In other words, just a normal push like any other
Main source: http://stackoverflow.com/a/5201642/348995
Source for info about when commits where already pushed: http://stackoverflow.com/a/5668050/348995
git checkout master && git fetch && git pull
git pull
is a synonym forgit fetch && git merge
so your version willgit fetch
twice, although the second time it likely won't fetch anything, so it probably doesn't matter.git merge feature_branch
I think you are better to
The reason I say that is because if you've merged your feature_branch to your local master, how do you then push it to origin master with an opportunity for someone else to review & merge your commit? I don't think you can create a pull request from your local to a remote, only push directly,
Although, workflows in git differ, so this might work for you if no-one is reviewing the code and you are happy to just push direct to origin/master. If that's the case, creating branches is more of a convenience for working on multiple discrete changes and being able to switch between them cleanly.