Suppose I have 5 local commits. I want to push only 2 of them to a centralized repo (using an SVN-style workflow). How do I do this?
This did not work:
<
git push
Examples:
git push fc47b2
git push HEAD~2
Commits are linked together as a chain with a parent/child mechanism. Thus, pushing a commit actually also pushes all parent commits to this commit that where not known to the remote. This is implicitly done when you git push the current commit: all the previous commits are also pushed because this command is equivalent to git push HEAD.
So the question might be rewritten into How to push a specific commit and this specific commit might be HEAD~2, for example.
If the commits you want to push are non-consecutive, simply re-order them with a git rebase -i before the specific push.