I have read the manual for git diff here http://git-scm.com/docs/git-diff and I did not find an answer.
I'm using git diff origin/master
according to this format git diff [--options] <commit> <commit> [--] [<path>…]
(omitted commit == HEAD) after a git fetch
to see what changes have been done before I do my git merge origin/master
.
It's realy usefull and I can review the code before applying the changes. My only problem is that I'm working in a team and I want to know which commiter did the change on every file.
I did not find any option of git diff
that show the committer. What's the easiest way to see the committer (if possible with git diff
)
EDIT :
I see that my question was not detailled enough.
For example, when I do a git diff
I get:
--- a/path/to/my/file.html
+++ b/path/to/my/file.html
@@ -xx,y +xx,y @@
- {% if sett.value|lower != "false" %}
+ {% if sett.value|lower != False %}
So I know that someone change this line and commit it. Idealy I want to have something like :
User John Doe commit the following :
--- a/path/to/my/file.html
+++ b/path/to/my/file.html
@@ -xx,y +xx,y @@
- {% if sett.value|lower != "false" %}
+ {% if sett.value|lower != False %}
Presuming you are on a tracking branch then you can do
git log HEAD..@{u} -p
You can tweak the arguments to log to display exactly the information that you want if the defaults don't suit you, but that should be pretty close to what you want. To explicitly show the committer you could use --pretty=fuller
or add %cn
and/or %ce
to your pretty format to specify the committer name and email respectively.
Of you aren't using a tracking branch then replace @{u}
with branch you want to merge from (origin/master
)
git diff
is probably not the tool you want if you're looking to find out who modified certain lines of code.
You could try using git blame
which "annotates each line in the given file with information from the revision which last modified the line".
EDIT: If you're in the situation described in your comment where you have done git fetch
and want to see the committers of any commits that you haven't yet merged in, then you can use git log <remote>/<branch_name>
. You could then limit the output to the number of commits that origin is ahead by, for example git log -2 origin/master
would let you find out the committers of the 2 commits that you have not yet merged into your local master branch.
EDIT2: Try git show
, which for commits "shows the log message and textual diff" (including the committer). It works on a single commit, so you will need to specify which one you want to look at, there are many ways to do this such as getting the commit hash, using syntax such as origin/master^
, etc.
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