Situation: A local repository has branch A and branch B. Branch B is ahead of branch A by, let's say, 30 commits.

First question: Can I list all the commits that are in B that are not in A ?

Second question: Let's say I cherry pick some (completely random) commits from B into A. What will happen if after that I try to merge B into A? Will I get duplicated commits? Can this be avoided somehow?

有帮助吗?

解决方案

As for the first question,

git log --left-right --graph --cherry-pick --oneline B...A

to get a list of different commits between the branches.

After merging one branch with the other git will automatically keep only one copy of duplicate commits. In any case if any conflict, git will ask you to resolve it manually.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top