You can use “git show” command to get details of a commit in git. You can find the author of the commit in the output. You can also get details such as timestamp, commit number, code changes.
Let us see through a hands-on example.
Use “git branch” and “git log” to see the list of commits. The branch is called as main, and there are five commits listed.
~/repoone$ git branch * main ~/repoone$ git log --oneline 4632c0d (HEAD -> main, origin/maincopy) Adding empty directory 908d6ac (origin/main, origin/HEAD) Third commit in main 42296d0 Second commit in main 453424e This is first commit 2673111 Initial commit
You can use “git show <commit number>” to get the details of a specific commit. This would provide the commit number, branch details, author, date, and changes in code.
~/repoone$ git show 4632c0d commit 4632c0d520218e90d6f6645e80773d9b7e8ab0f7 (HEAD -> main, origin/maincopy) Author: Code Version Master <email@example.com> Date: Sat Sep 24 13:04:50 2022 +0000 Adding empty directory diff --git a/dirtwo/.gitignore b/dirtwo/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/dirtwo/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore
You can add extra filters to the same command to get specific fields such as Author.
~/repoone$ git show 4632c0d | grep Author Author: Code Version Master <firstname.lastname@example.org>