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
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
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}
git push <remotename> <commit SHA>:<remotebranchname>
should do the trick.
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.