

Ali Heydari
Browsing history
getting a repository
clone the website repo
viewing the history
git log
navigaion with space, up and down arrow keys, and q for quit
git loggit log --onelinegit log --statgit log --oneline --statgit log --patchorgit log -p
filtering the history
filter by author:
git log --oneline --author="Ali Heydari"
filter by specific date:
git log --after 2021-09-11git log --before 2021-09-11git log --after 2021-09-11 --before 2021-09-30
filter by releative date:
git log --after "one week ago" --before "yesterday"
filter by commit message:
git log --oneline --grep="feat" (note that grep is case sensitive)
filter by content:
git log --oneline -S"React.FC = (props)"git log --oneline -S"React.FC = (props)" --patch
filter by paticular range:
git log --oneline 7bdaa1d..a7608d6
filter all commits that modified paticular file:
git log --oneline _app.tsxgit log --oneline -- _app.tsxgit log --oneline --patch _app.tsx
formatting the log output
git log --pretty=format:"%an commited %h on %cd"git log --pretty=format:"%Cgreen%an%Creset commited %Cred%h%Creset on %cd"
aliases
git config --global alias.lg "log --pretty=format:'%Cgreen%an%Creset commited %Cred%h%Creset on %cd'"git config --global alias.unstage "restore --staged ."
viewing a commit
git show HEAD~20git show HEAD~20:pages/_app.tsxgit show HEAD~20 --name-onlygit show HEAD~20 --name-status
viewing the changes across commits
git diff HEAD~2 HEADgit diff HEAD~2 HEAD --name-onlygit diff HEAD~2 HEAD --name-status
checking out a commit
git checkout SHA1
finding bugs using bisect
git bisect start
git bisect bad
git bisect good SHA1
git log --oneline --all
# ...
git bisect reset
finding contributors using shortlog
git shortloggit shortlog -hgit shortlog -ngit shortlog -egit shortlog -n -s -e --before="2021-09-11" --after="2021-09-30"
viewing the history of a file
git log --oneline .github/workflows/deploy.ymlgit log --oneline --stat .github/workflows/deploy.ymlgit log --oneline --patch .github/workflows/deploy.yml
restoring a deleting file
git log --oneline -- DELETED_FILE
git checkout SHA1 DELETED_FILE
finding the author of line using blame
git blame package.jsongit blame -e package.jsongit blame -e -L 1,10 package.json
tagging
git tag v0.0.2git tag SHA v0.0.1git tag -a v0.0.1-alpha -m "open alpha version"git tag -d v0.0.1-alpha
Attachments: [session video 📺](\\192.168.100.14\Training Courses\git)
Tags:lecture