If I have master branch and merge in commits from branch foo multiple times, is there a command to find all those commits?
0
votes
You cannot merge the same commit multiple times. Can you draw us a graph to clarify what you're trying to do?
– matt
Sorry I think my writing isn’t good here. So if I have a master branch and create a feature branch off of master. Now let’s say I make 2 commits on the feature create a merge pull request into master and then merge it into master. Now 1 week later I make another 2 commits on feature then again merge it into master. Is there a way in master to find all those commits that were merged in or all the merged that happened (feature -> master)?
– FriedRice
But you shouldn't do that. Once you have submitted a PR and it is accepted and merged, you must delete that branch. Terrible things will happen if you try to repeatedly merge a long lived feature branch.
– matt
@matt I don't know what terrible things will happen, unless you starting rebasing or amending your history. Merging a branch multiple times is generally not a problem for Git (at least none that I'm aware of) – the DAG takes care of properly resolving such merges.
– knittl
1 Answers
0
votes
Finding the oldest merge base of two first-parent histories is an easy enough request,
oldestbase=$(
(git rev-list --first-parent mainline; git rev-list --first-parent feature) \
| awk 'seen[$0]++ {print;exit}'
)
and then your list of feature
commits to check is
git rev-list --first-parent --no-merges $oldestbase..feature