Cherrypick placing orders

This might be a naive git question, but here it is:

Before making a pull request, I usually create a new branch from the latest commits in the upstream and cherry-picking important commits from my development branch. Then make a pull request from my new branch to the remote repository.

But I hate merge conflicts (although git mergetool helps a lot when they arise). I suspect some of these conflicts are caused by the order of the cherry picks. I usually scribble a set of commits from oldest to newest. This is the correct approach. Or is committing the order irrelevant to git?

Are there any other tricks to minimize merge conflicts when typing cherries?

+3


source to share


2 answers


You must make sure the cherry grip is in order. If you don't, they might not apply - imagine one command adds foo.c and the next changes it. Obviously, they will not fail. In general, even if it's not so obvious, there is some logical flow of development and you don't want to mess with it. However, I'm not sure why you are manually creating the branch and cherry; it's equivalent (as long as you don't miss commits) to git pull --rebase

.



If you get merge conflicts while typing cherries, it's more of a sign that your development process isn't perfect. This means that the things you are working on in your development branch also change upstream. You may be able to help yourself by not working on the same code that others are working on, or by pulling (possibly pull --rebase

again) from the upstream more often during development rather than waiting until the very end.

+7


source


Absolutely, the order of the order matters. If commit B modifies stuff that was first introduced in commit A, then you can't apply commit B until commit A.



Your workflow is weird. You have to either git rebase

your branch to rebuild it on top of the content of the upstream branch, or just git merge

branch upstream into yours. This avoids cherry-picking and gives git a better chance to automatically resolve conflicts.

+2


source







All Articles