How can I find out the authors of the current commit and its parent commit?

时间:2016-08-31 18:38:40

标签: git

I am currently looking at my old feature branch which has been merged into the master branch by someone else.

After I switched to my feature branch, I found that git diff master...<my-branch> showed some changes that I don't think were made by me.

I guess that the person who did the merge made some changes and created a new commit on my feature branch, before making the merge.

So how can I find out the author of the current commit and the author of its parent or more older ancestor commits?

Thanks.

3 个答案:

答案 0 :(得分:2)

使用:

> git blame <file>

分析任何文件的每一行的作者,

或使用:

> git log --graph master

分析当前和旧提交的提交图和提交作者。

答案 1 :(得分:1)

You can use 'git blame'

Git Blame Documentation

Run 'git blame ' and review the lines that you think have changed, or check the dates for latest changes. The abbreviated hash will also be available if you want to spelunk the code and checkout previous versions. 'blame' in association with 'git log --name-status' should get you where you want to go.

答案 2 :(得分:1)

使用git checkout <branch-name>切换到您正在讨论的分支,然后运行命令:

git log -1 --pretty=medium --stat -p

这将打印上次提交的日志(-1选项,如果要查看更多日志,则删除它),并使用作者姓名--pretty=medium。将其更改为--pretty=full查看更多)和提交中引入的更改的统计信息(--stat选项)以及对更改的文件应用的diff命令(-p选项)。