As far as I understand, you have something like this:
A -- B -- C -- D -- E
\ \- master
\- origin/master
and you want to add commit E
to your remote repository, but you don't want C
and D
.
Then you should cherry-pick E
:
git checkout B # use for instance the sha1 of this commit
git checkout -B BES-22 # it creates the branch BES-22 locally and puts you on it
git cherry-pick E
At this point you have:
A -- B -- C -- D -- E
\ -- E' \-master
\ \- BES-22
\- origin/master
So you can push:
git push origin BES-22
In particular, note that:
Since commits are immutable in Git, the cherry-pick
created a brand new commit E'
If you have the error error: unable to push to unqualified destination: BES-22 The destination refspec neither matches an existing ref on the remote nor begins with refs/, and we are unable to guess a prefix based on the source ref.
, it more or less means that branch BES-22
doesn't exist on the remote. Using git push origin <branch>
instead of git push origin <sha1>:<unexisting remote branch>
should fix it