What does git log do?
The git log command display all the commits history in a repository.
By default, the command displays for each commits:
- Secure Hash Algorithm (SHA)
- author
- date
- commit message
Git log options
You can customize the information provided by git-log
by passing the options.
--oneline
The --oneline
option causes git log
to display each commit in one line
- The first seven characters of SHA
- The commit message
8fc4335 first commit 09cca7e Initial commit
--patch or -p
or, the shorter version
The --patch
option causes git log
to display
- Commit id, Author, Date, and commit message.
- The files have been modified, addition/deletion in files.
- The specific changes that happened in this commit. Like addition and deletion of changes.
- Line number where addition/deletion happened.
You can see something like below, when you run git log --patch
Author: SantoshDate: Sun Aug 23 18:02:21 2020 +0530 initial commit diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@
-- <absolute/relative path of file>
When you want to see the changes of specific file then you can write git log -- file name. Make sure that there is space between the -- and file name.
The -- filename
causes git log
to display only specific commit happened to this file
only
- Secure Hash Algorithm
- author
- date
- commit message
This will display recent commit first or can say in descending order of timestamp.
--oneline <absolute/relative path of file>
The --oneline filename
causes git log
to display only specific commit happened to this
file
only
- The first seven characters of SHA
- The commit message
Commit made by particular author
You can see the commit made by specific user using the below command.
Start at specific commit
You can display display the commit with specific SHA and all of the commits made before that commit.
You can combine with other available options.
Search commit message
You can search commit message using the --grep
.
--graph
The --graph
options enables you to view your git log
as a graph. You can combine this
with --oneline
option you have learned from above.
The --graph
option is very useful in git log
when you are working on feature on which
multiple developers are working.
You can combine with --decorate
option.
Nice article
ReplyDeleteNice
ReplyDelete