I have this (git repo):
A--B--C--D ->master
\--E ->dev
And I want to bring only commit D
to branch dev
(D
doesn't depend on C
), so that:
A--B--C--D ->master
\--E--D' ->dev
But D' shouldn't get added to master after a merge:
A--B--C--D--E' ->master
\--E--D'/ ->dev
This is because I want to bring only a file update without having to pollute dev
with new files that C
(which represents another, big merge) adds.
I'm guessing I need to use git rebase
, but I can't guess how.
You want to use git cherry-pick
. I'll assume your remote is named "origin" (but substitute the real name of the remote repo for "origin"). I'll assume you have two local branches also named master
and dev
. I'll assume commit D is on origin/dev
. You can cherry-pick D with the following:
$ git fetch origin # Assuming the upstream remote's name is "origin"
$ git checkout dev # Check out your local "dev" branch
$ git cherry-pick $COMMIT_D # Replace "COMMIT_D" with the hash for commit D
Now you'll only have the changes from commit D in dev
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With