

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 log
git log --oneline
git log --stat
git log --oneline --stat
git log --patch
orgit log -p
filtering the history
filter by author:
git log --oneline --author="Ali Heydari"
filter by specific date:
git log --after 2021-09-11
git log --before 2021-09-11
git 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.tsx
git log --oneline -- _app.tsx
git 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~20
git show HEAD~20:pages/_app.tsx
git show HEAD~20 --name-only
git show HEAD~20 --name-status
viewing the changes across commits
git diff HEAD~2 HEAD
git diff HEAD~2 HEAD --name-only
git 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 shortlog
git shortlog -h
git shortlog -n
git shortlog -e
git shortlog -n -s -e --before="2021-09-11" --after="2021-09-30"
viewing the history of a file
git log --oneline .github/workflows/deploy.yml
git log --oneline --stat .github/workflows/deploy.yml
git 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.json
git blame -e package.json
git blame -e -L 1,10 package.json
tagging
git tag v0.0.2
git tag SHA v0.0.1
git 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