Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git cherry-pick without checkout? [duplicate]

I wonder if there is the way to copy one commit to another branch without checking out that branch.

For example, I have two branches: master and parallel_version.

I'm on parallel_version branch and I found a bug in file common for these branches.

I've fixed it and committed. How to duplicate this commit to another branch, assuming I'm using git-svn?

Normally I would do:

$ git checkout master
$ git cherry-pick parallel_version
$ git checkout parallel_version

Is there better way of doing that?

like image 501
kassak Avatar asked Nov 21 '22 23:11

kassak


2 Answers

That's not possible - simply imagine what would happen if there was a conflict that couldn't be resolved automatically. For the same reason you also can't update branches that are not currently checked-out (even if a fast-forward was possible).

like image 71
ThiefMaster Avatar answered Nov 23 '22 12:11

ThiefMaster


https://github.com/lennartcl/gitl provides "git cherry-copy" and "git cherry-move" scripts that do this and handle most of the corner cases.

like image 37
lennartcl Avatar answered Nov 23 '22 12:11

lennartcl