Tim
Tim

Reputation: 99418

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

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.

Upvotes: 0

Views: 103

Answers (3)

joker
joker

Reputation: 3752

Switch to the branch you are talking about using git checkout <branch-name> and run the command:

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

This prints the log of the last commit (the -1 option, remove it if you want to view more logs) with the author name (--pretty=medium. Change it to --pretty=full to view more) and the stat of the changes introduced in the commit (the --stat option) along with the diff command being applied on the files changed (the -p option).

Upvotes: 1

Use:

> git blame <file>

to analyse the authors of each line of any file,

or use:

> git log --graph master

to analyse the commit graph and the commit authors for the current and old commits.

Upvotes: 2

Travis Rodman
Travis Rodman

Reputation: 637

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.

Upvotes: 1

Related Questions