Cheatsheet Git A4
Cheatsheet Git A4
Name Comment
Git squash to make history clean git rebase -i HEAD~4; git push origin <branch-name> --force
Find git branch by commit hash https://\protect\T1\textdollar\{git_repo_link\}/commit/\protect\T1\textdolla
List all remote git branches git ls-remote --heads origin
Git clone repo with another ssh key ssh-agent bash -c ’ssh-add yourkey; git clone [email protected]:user/project.git’
Git clone to a specific folder git clone https://github.com/google/cadvisor.git /go/src/github.com/google/c
Code Owners Define individuals or teams that are responsible for code in a repository.
https://raw.githubusercontent.com/dennyzhang/cheatsheet-git-A4/master/git-concept.png
Name Comment
git sh1sum git log -1 --pretty=format:%h
Check recent commits git log -n 3
Show change content between tow commits git log --pretty=oneline --abbrev-commit 1234...5678
Check commit by username git log origin/master -n 3 --author <denny>
Check changes for a given file from a given user git log origin/master -n 3 --author <denny> <somefile.py>
GitHub: https://github.com/dennyzhang/cheatsheet-git-A4 1 of 2
Blog URL: https://cheatsheet.dennyzhang.com/cheatsheet-git-A4 Updated: June 7, 2020
Name Comment
Compare git diff after commit git diff --cached
Compare two git tags git diff ${sha1sum}..${sha2sum}
Show changed file list git diff --name-status, git diff --name-status --cached
Git diff two revision git diff ${sha1sum}..${sha2sum}
Git show file changes git diff --name-only ${sha1sum} ${sha2sum}
Show changeset of the latest commit git diff HEAD^
Show prvious changeset for one file git diff HEAD^ default.rb
Compare two branches in CLI git diff <branch_1>..<branch_2> Make sure you have those branches locally
Compare two revision in GitHub UI https://github.com/. . . /. . . /compare/sha1. . . sha2
Compare latest 3 commits in GitHub UI https://github.com/dennyzhang/cheatsheet-git-a4/compare/HEAD~3...HEAD
Name Comment
Show git config git config --global/system
Configure default editor export pager=cat, git config --global core.editor nano
Edit git global config git config --global --edit
Alias for git status git config --global alias.st status Link: git aliases
Alias for git checkout git config --global alias.co checkout
Alias for git commit git config --global alias.ci commit
Reset git url git config --global url."[email protected]:dennyzhang/myrepo.git:".insteadOf "https://git
Reference GitHub: gitignore examples
1.11 GitHub
Name Comment
Github Shortcut Link: Using keyboard shortcuts
Generate TOC gh-md-toc
Reference link: generate link for code block, link: git clone wiki repo
GitHub: https://github.com/dennyzhang/cheatsheet-git-A4 2 of 2