I have a master branch and another named release/system2. I had several commits pushed to the master branch, and two days ago, I made a merge to release/system2. After that, system2 broke the system due to some issues in the latest code in the master branch. Is there any way I could check which commits were merged into the release/system2 branch two days ago, ignoring the commits merged before that specific day?
2 Answers
Check all git log by date range:
git log --pretty=format:"%ad - %an: %s" --after="2016-01-31" --until="2023-03-10"
result:
Mon Jul 25 22:38:56 2022 +0500 - zakk: implemented mongo altas
Sun Jul 24 23:53:57 2022 +0500 - zakk: implemented mongodb
Sat Jul 23 18:30:32 2022 +0500 - zakk: applied css
Thu Jul 21 21:29:22 2022 +0500 - zakk: fisrt commit
check git log by formating the date:
$ git log --pretty=format:"%h - %an, %ar : %s"
result:
86d00ca - zakk, 3 days ago : implemented mongo altas
987cdb5 - zakk, 4 days ago : implemented mongodb
8f9240b - zakk, 5 days ago : applied css
10f1e4e - zakk, 7 days ago : fisrt commit
Note: this will print all log including commits
and merges
Let's call the merge commit ID created by the merge of master
into release/system2
commit M
.
All of the commits brought into release/system2
by that merge can be identified with:
git log M~1..M
Perhaps equally helpful in identifying the problem file(s) would be a diff of those same two commits (parent 1 of the merge commit with the merge commit).
Note: this assume the first-parent is in fact the previous version of release/system2
before the merge. This would normally be the case, but it's possible it could be backwards, for example if that merge had conflicts that you had to resolve, and if your temporary branch used to resolve them started from master
and merged in release/system2
instead of the other way around, and then if you merged that temporary branch into release/system2
using a fast-forward merge. If you're in this scenario then use M^2
instead of M~1
.