If my-feature-branch
was merged into my-main-branch
, how can I see what commits were merged in from my-feature-branch
?
It shows all the changes made to the merged branch as a result of the merge. Show activity on this post. git show -c c0f501 will display a combined diff from commit c0f501 to both of its parents, as printed by git diff during a merge. This gives a better overview than git show -m .
THE MERGE COMMIT For instance, when a branch named feature is merged with master, a new commit is created on the branch master which has two parents, the previous head of master and the head of feature. On merging the feature to master. These commands create a new merge commit 1c32600.
If you see the commit history in the screen BitBucket UI view, It brings the merge commit history with timestamp instead of actual merge commit timestamp.
`git log` command is used to view the commit history and display the necessary information of the git repository. This command displays the latest git commits information in chronological order, and the last commit will be displayed first.
git log abc123^..abc123
shows the commits that got merged into merge-commit abc123
.
Create a git
alias log-merge
for easy reuse:
$ git config --global alias.log-merge \
'!f() { git log --stat "$1^..$1"; }; f'
$ git log-merge abc123
For a one-line version:
$ git config --global alias.log-merge-short \
'!f() { git log --pretty=oneline "$1^..$1"; }; f'
If you want to see every commits merged in the last merge you can try that :
git log $(git merge-base --octopus \
$(git log -1 --merges --pretty=format:%P)).. --boundary
Here is an example of my current log :
$ git log --graph --pretty=oneline --abbrev-commit
* 44899b9 pouf
* 8f49f9c Merge branch 'test'
|\
| * 3db39ca test
* | 69f431c pif
* | df1f51c lala
|/
* 8fae178 pif2
* 20f8ba6 init
If I only want commits related to the last merge I have to use git log -1 --merges --pretty=format:%P
which gives me the parents of the first merge available :
$ git log -1 --merges --pretty=format:%P
69f431cec7859b61d33c7503c9431ceea2aaf3e0 3db39ca3ab1e8f70462db23d94590628b5e7ad7b
Now that I know which parents I need to track, I need their common base that I can obtain through git merge-base --octopus
(--octopus is there just in case) :
$ git merge-base --octopus \
$(git log -1 --merges \
--pretty=format:%P)
8fae178666e34a480b22e40f858efd9e7c66c3ca
Now with git log
I can search every commit since the base to the current HEAD
:
$ git log $(git merge-base --octopus \
$(git log -1 --merges --pretty=format:%P)).. \
--boundary --graph --pretty=oneline --abbrev-commit
* 44899b9 pouf
* 8f49f9c Merge branch 'test'
|\
| * 3db39ca test
* | 69f431c pif
* | df1f51c lala
|/
o 8fae178 pif2
If you're a bit perfectionist you can also do this :
$ git log
$(git merge-base --octopus \
$(git log -1 \
--merges --pretty=format:%P))..$(git log -1 --merges --pretty=format:%H) \
--boundary --graph --pretty=oneline --abbrev-commit
* 8f49f9c Merge branch 'test'
|\
| * 3db39ca test
* | 69f431c pif
* | df1f51c lala
|/
o 8fae178 pif2
Now I think I'll keep this as an alias :)
The --graph --pretty=oneline --abbrev-commit
options are optional.
Resources :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With