This might be a repeated question but i didn't find exact answers.
Lets say i have 2 branches br1 and br2 with 3 commits each.
br1
- commit a
- commit b
- commit c
br2
- commit d
- commit e
- commit f
When i merge from br2 to br1, git log on br1 show commits a,b,c,d,e,f.
Lets say i have 2 branches br1 and br2 with 3 commits each.
br1 after merge with br2
- commit a
- commit b
- commit c
- commit d
- commit e
- commit f
Is there a way to filter commits that were created on br1 alone? (开发者_开发问答I have tried git log br1..br2 but is there any other method?)
If the merge was Fast-forward or Automerge, will GIT record any commit for the merge? (i see commit when there is a conflict but not in an automerge)
A branch is just a pointer to a specific commit. So you can't find out from what branch a certain commit came from.
When doing a fast-forward, the only thing that changes is that the commit a certain branch points to is switched, so no extra commit will be recorded. If you do want an extra commit to be recorded, use git merge --no-ff
.
I'm not certain why this is important to know, but if it is, then you could create a new branch from br1 and use that branch to merge br2. Then br1 and br2 are unchanged, and you can tell which one includes which changes, while you also have a merge branch containing both sets of changes.
br1
- a
- b
- c
br2
- d
- e
- f
mbr1_2
- a
- b
- c
- d
- e
- f
The problem with git log br1..br2
is that it will try to suppress the commits the commits that are part of br1, but all the commits are part of br1 now, so nothing will show.
What you can do is find the commit right before the merge of br2; git log br1^..br2
, but that would only work only if br1 has not moved forward.
In general the best way is to find out the relevant merge, and show the commits that were merged:
git log merge^1..merge^2
精彩评论