tags:

views:

67

answers:

3

I have made several commits on different files, but so far I would like to push to my remote repository only a specific commit.

Is that possible? Thanks

A: 

I believe you would have to "git revert" back to that commit and then push it. Or you could cherry-pick a commit into a new branch, and push that to the branch on the remote repo. Something like :

git branch onecommit
git checkout onecommit
git cherry-pick 7300a6130d9447e18a931e898b64eefedea19544 # From the other branch
git push origin {branch}
Josh K
git revert is a bad idea here -- it creates a new commit
hasen j
@hasen: You could then just `cherry-pick` the commit you want.
Josh K
+5  A: 

git push <remotename> <commit SHA>:<remotebranchname> should do the trick.

Geoff Reedy
+1 I was looking for something like this but I didn't find it.
Josh K
A: 

I'd suggest using git rebase -i; move the commit you want to push to the top of the commits you've made. Then use git log to get the SHA of the rebased commit, check it out, and push it. The rebase will have ensures that all your other commits are now children of the one you pushed, so future pushes will work fine too.

Walter Mundt