General syntax:

$git push origin <local-branch-name>~<count down from the top to exclude those many commits>:<upstream-branch-name>

I had 4 commits:

Screenshot from 2013-06-28 09:57:33

The one at the bottom, was already part of my upstream. I wanted to push the next two commits, but not the topmost one.

Commits in my upstream Commits I want to push Commits I want to exclude
New page key-photoid.page Edited key-photoid.page Draft for key-subkeys.page
New page key-new-userid.page

For me, the command was,

$git push origin mallard-help~1:mallard-help

My local and upstream branches are called mallard-help.
I wanted to push all commits except the top most commit, so I had to count down one commit.

Your commits should be ordered in terms of

Older<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Newer

Commits to be pushed<<<<<<<<<<<<<<<<<<<<<<<<<Commits that need work

You can always use an interactive rebase to achieve the above effect.

Advertisements