rogerxu / git-tips

Tips for Git
Apache License 2.0
2 stars 3 forks source link

Log #33

Open rogerxu opened 6 years ago

rogerxu commented 6 years ago

Git - git-log Documentation

Ten Useful Git Log Tricks | Hacker Noon

rogerxu commented 6 years ago

shortlog

Git - git-shortlog Documentation

Show sorted list by number of commits for each author in all branches.

$ git shortlog -n -s -e --all
rogerxu commented 6 years ago

log

Show what changed for one week.

$ git log --no-merges --raw --since='1 week ago'

Show graph log with 10 commits.

$ git log --graph --decorate --oneline --all -10

Alias

$ git config --global alias.lg "log --graph --decorate --oneline --all --color=always"
$ git config --global alias.lg "log --graph --decorate --all --pretty=format:'%C(auto)%h%d %Creset%s %C(green)(%cr) %C(blue)<%cn>' --color=always"
$ git config --global alias.ls "log --pretty=format:'%C(yellow)%h %C(green)%ci%C(auto)%d %Creset%s %C(blue)<%cn>'"
$ git config --global alias.ll "log --pretty=format:'%C(yellow)%h %C(green)%ci%C(auto)%d %Creset%s %C(blue)<%cn>' --numstat"
$ git lg -10

Auto refresh in every 2 seconds

$ watch --color git lg -10
rogerxu commented 3 years ago

Format

$ git log --oneline
$ git log --abbrev-commit --pretty=oneline
$ git log --graph --decorate --all --pretty=format:'%C(auto)%h%d %Creset%s %C(green)(%cr) %C(blue)<%cn>' --color=always
rogerxu commented 2 years ago

Filter

Time

git log --after="2020-05-20" --before="2020-10-08"
git log --after="yesterday"
git log --after="today"
git log --after="2 week ago"

Author

git log --author="roger"

Message

Search with case insensitive

git log -i --grep="fix-123"
git log -i --grep="fix-123\|fix-456"

File

git log file.js

File Content

git log -i -S"function foo()"
rogerxu commented 2 years ago

Diff

Show diff content

git log -p

Show diff commits

git log master..develop