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?
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?
The simplest way to accomplish this is with two commands.
First, get the local directory into the state that you want. Then,
git push origin +HEAD^:someBranch
removes the last commit from someBranch in the remote only, not local. You can do this a few times in a row, or change +HEAD^ to reflect the number of commits that you want to batch remove from remote. Now you're back on your feet, and use
git push origin someBranch
as normal to update the remote.
You could also, in another directory:
I just used
git cherry-pick 'sha id of the commit'
and then
git push
In my case my local branch name was 'master' and the remote default branch name was 'master' too.