Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use git cherry-pick now but merge changes later

Tags:

git

git-merge

I have two branches and want to cherry-pick a change from one and move it to the other. At a later date, when I merge the two repositories what effect will the cherry-pick have since the commit IDs will be different but the content will be the same.

like image 444
user3948 Avatar asked Nov 21 '10 03:11

user3948


People also ask

Can I merge after cherry pick?

With the cherry-pick command, Git lets you incorporate selected individual commits from any branch into your current Git HEAD branch. When performing a git merge or git rebase , all the commits from a branch are combined. The cherry-pick command allows you to select individual commits for integration.

Should you cherry pick a merge commit?

You should cherry-pick a commit when you need the change contained in a single commit, but you can't or don't want to pull the entire contents of that branch into another. You can use the GitLab UI to cherry-pick single commits or entire merge requests. You can even cherry-pick a commit from a fork of your project.

How do I change commit message after cherry pick?

To change the commit message when cherry-picking, use “git cherry-pick” with the “-e” option. As illustrated in this example, your default editor will open and it will let you change the commit message. When you are satisfied with the edits, save your file and your commit message should be saved successfully.

Is it possible to get merge conflict during git cherry pick?

Yes, at least with the standard git setup. You cannot cherry-pick while there are conflicts. Furthermore, in general conflicts get harder to resolve the more you have, so it's generally better to resolve them one by one.


1 Answers

As long as the changed region is not affected in a later commit, the merge will ignore the regions changed in the cherry-pick, since they will be identical in each branch. If you later change one of the regions in one branch but not the other, you may have to resolve a conflict as usual.

like image 88
cdhowie Avatar answered Nov 15 '22 17:11

cdhowie