Reputation: 6836
How do I can get in which commit did a change happen?
I have 67 commits in a pull request. There's a mistake in the final diff with code that should be there and is being removed. How do I solve such thing? How do I know in which commit is that piece of code that is changing the final merge diff?
Upvotes: 1
Views: 818
Reputation: 2183
Filtering on file path also gets you a quick answer, often:
git log --pretty=oneline -- src/main/java/com/brunoais/Foo.java
That'll display only the commits affecting the file src/main/java/com/brunoais/Foo.java
, with comments in the right-hand column of the output.
Here's the breakdown.
The --
part is the path specification prefix. It can be applied to other git commands, not just git-log. (It's often optional; git only needs --
if there's ambiguity, e.g., if the file path happens to be the same as a branch name.)
The --pretty=oneline
part makes the output concise.
Upvotes: 0
Reputation: 14061
If the code is already commited you can use git blame
to find what happened 6.5 Git Tools - track down a bug in your code and want to know when it was introduced and why.
If the code is on Github you can simply use the Blame button when looking at the relevant file. I use this method a lot for looking at git & msysgit itself (to know who's toes I might be stepping on ;-).
Upvotes: 3
Reputation: 61
If you know what that missing piece of code is you could do:
git log -p
and then search through for that missing piece of code and which commit removes it.
Upvotes: 0