git log
Prints details of all commits reachable from HEAD
commit af7725caab2d197f07c72f6d9a4814d5d9ce9e53 Author: Nitin Nizhawan <abc@example.com> Date: Sat Feb 27 21:01:30 2016 +0530 Commit D commit 662b3caf91bbb8faf56ef7262615a8828b381be1 Author: Nitin Nizhawan <abc@example.com> Date: Sat Feb 27 21:01:16 2016 +0530 Commit C commit f46d0d9949274bba7f797a5b63bc004f291905b4 Author: Nitin Nizhawan <abc@example.com> Date: Sat Feb 27 21:01:03 2016 +0530 Commit B commit bbb738746b14e8e4ac09a443e9ac1c931ad61d07 Author: Nitin Nizhawan <abc@example.com> Date: Sat Feb 27 21:00:29 2016 +0530 Commit A
git log --abbrev-commit
Prints details of all commits reachable from HEAD but it prints SHA of commit in abbreviated form
commit af7725c Author: Nitin Nizhawan <abc@example.com> Date: Sat Feb 27 21:01:30 2016 +0530 Commit D commit 662b3ca Author: Nitin Nizhawan <abc@example.com> Date: Sat Feb 27 21:01:16 2016 +0530 Commit C commit f46d0d9 Author: Nitin Nizhawan <abc@example.com> Date: Sat Feb 27 21:01:03 2016 +0530 Commit B commit bbb7387 Author: Nitin Nizhawan <abc@example.com> Date: Sat Feb 27 21:00:29 2016 +0530 Commit A
git log --oneline
Print abbreviated SHA and commit msg summary in one line
af7725c Commit D 662b3ca Commit C f46d0d9 Commit B bbb7387 Commit A
git log -g
Print reflog formatted as git log
commit af7725caab2d197f07c72f6d9a4814d5d9ce9e53 Reflog: HEAD@{0} (Nitin Nizhawan) Reflog message: checkout: moving from testBranch to master Author: Nitin Nizhawan Date: Sat Feb 27 21:01:30 2016 +0530 Commit D commit 662b3caf91bbb8faf56ef7262615a8828b381be1 Reflog: HEAD@{1} (Nitin Nizhawan ) Reflog message: checkout: moving from master to testBranch Author: Nitin Nizhawan Date: Sat Feb 27 21:01:16 2016 +0530 Commit C commit af7725caab2d197f07c72f6d9a4814d5d9ce9e53 Reflog: HEAD@{2} (Nitin Nizhawan ) Reflog message: reset: moving to af7725c Author: Nitin Nizhawan Date: Sat Feb 27 21:01:30 2016 +0530 Commit D commit 662b3caf91bbb8faf56ef7262615a8828b381be1 Reflog: HEAD@{3} (Nitin Nizhawan ) Reflog message: reset: moving to HEAD^ Author: Nitin Nizhawan Date: Sat Feb 27 21:01:16 2016 +0530 Commit C commit af7725caab2d197f07c72f6d9a4814d5d9ce9e53 Reflog: HEAD@{4} (Nitin Nizhawan ) Reflog message: commit: Commit D Author: Nitin Nizhawan Date: Sat Feb 27 21:01:30 2016 +0530 Commit D
git log -g master
Print reflog in the format of git log for only master branch. Shows commits master has pointed to in you local workspace.
commit 20e9855e2b90ee6580c3b8db250dae0d9b18cff1 Reflog: master@{0} (Nitin Nizhawan <abc@example.com>) Reflog message: commit: Commit E Author: Nitin NizhawanDate: Sun Feb 28 11:54:30 2016 +0530 Commit E commit af7725caab2d197f07c72f6d9a4814d5d9ce9e53 Reflog: master@{1} (Nitin Nizhawan <abc@example.com>) Reflog message: reset: moving to af7725c Author: Nitin Nizhawan Date: Sat Feb 27 21:01:30 2016 +0530 Commit D commit 662b3caf91bbb8faf56ef7262615a8828b381be1 Reflog: master@{2} (Nitin Nizhawan <abc@example.com>) Reflog message: reset: moving to HEAD^ Author: Nitin Nizhawan Date: Sat Feb 27 21:01:16 2016 +0530 Commit C commit af7725caab2d197f07c72f6d9a4814d5d9ce9e53 Reflog: master@{3} (Nitin Nizhawan <abc@example.com>) Reflog message: commit: Commit D Author: Nitin Nizhawan Date: Sat Feb 27 21:01:30 2016 +0530 Commit D
git log refA..refB
Print commits which are reachable from refB but not from refA
$$ git log --graph --pretty=oneline --abbrev-commit --all * 20e9855 Commit E * af7725c Commit D | * cb2e193 TestBranchB | * ac4148c Commit TestBranchA |/ * 662b3ca Commit C * f46d0d9 Commit B * bbb7387 Commit A $$ git log --oneline master..testBranch cb2e193 TestBranchB ac4148c Commit TestBranchA $$ git log --oneline testBranch..master 20e9855 Commit E af7725c Commit D
git log refB --not refA
Print commits which are reachable from refB but not from refA
$$ git log --graph --pretty=oneline --abbrev-commit --all * 20e9855 Commit E * af7725c Commit D | * cb2e193 TestBranchB | * ac4148c Commit TestBranchA |/ * 662b3ca Commit C * f46d0d9 Commit B * bbb7387 Commit A $$ git log --oneline testBranch --not master cb2e193 TestBranchB ac4148c Commit TestBranchA $$ git log --oneline master --not testBranch 20e9855 Commit E af7725c Commit D
git log ^refA refB
Print commits which are reachable from refB but not from refA
$$ git log --graph --pretty=oneline --abbrev-commit --all * 20e9855 Commit E * af7725c Commit D | * cb2e193 TestBranchB | * ac4148c Commit TestBranchA |/ * 662b3ca Commit C * f46d0d9 Commit B * bbb7387 Commit A $$ git log --oneline ^master testBranch cb2e193 TestBranchB ac4148c Commit TestBranchA $$ git log --oneline ^testBranch master 20e9855 Commit E af7725c Commit D
git log refA...refB
Print commits which are reachable from refA or refB but not both
$$ git log --graph --pretty=oneline --abbrev-commit --all * 20e9855 Commit E * af7725c Commit D | * cb2e193 TestBranchB | * ac4148c Commit TestBranchA |/ * 662b3ca Commit C * f46d0d9 Commit B * bbb7387 Commit A $$ git log --oneline master...testBranch 20e9855 Commit E cb2e193 TestBranchB ac4148c Commit TestBranchA af7725c Commit D $$ git log --oneline master...testBranch --left-right < 20e9855 Commit E > cb2e193 TestBranchB > ac4148c Commit TestBranchA < af7725c Commit D
git log --show-signature
Also show signature information
git log -Sterm
Search for commits which either removed or added "term" to the repo
git log -L {start_line_no},{end_line_no}:{filepath}
Search commits which modified lines starting from start_line_no to end_line_no in file filepath
git log -L /{start_regex}/,/{end_regex}/:{filepath}
Search commits which modified lines starting lines which match start_regex to line which match end_regex in file filepath