Git Cheat Sheet
Need a πππ πππππ πππππ?
1. πͺπππ:
β’ git init [initialize git repo]
β’ git clone [clone a remote repo]
β’ git add [add file(s) in git]
β’ git commit [save the current state of the file]
β’ git status [show uncommitted changes]
β’ git diff [view the changes]
β’ git reset [reset current HEAD to the specified state]
β’ git log [show commit logs]
β’ git show [shows one or more objects (blobs, trees, tags and commits)]
β’ git tag [create, list, delete, or verify a tag object signed with GPG]
β’ git push [update remote (should pull first after a commit)]
β’ git pull [Fetch and merge (from remote/local)]
β’ git checkout [switch branches or restore working tree files]
2. π©ππππππππ:
β’ git branch [show branch list, create, or delete branches]
β’ git merge [join two or more histories together]
β’ git rebase [reapply commits on top of another base tip]
β’ git checkout -b | -B [create a new branch if not exist (reset if -B)]
β’ git branch β set-upstream-to=<upstream> [reassign upstream]
β’ git branch β unset-upstream [Remove the upstream information]
β’ git cherry-pick [chose a commit from one branch and apply to another (cousin of merge, rebase)]
3. π΄ππππππ:
β’ git merge [join two or more histories together]
β’ git rebase [reapply commits on top of another base tip]
4. πΊπππππππ:
β’ git stash [dump the changes (recoverable)]
β’ git stash pop [remove a single stash and apply]
β’ git stash list [show list the stash entries]
β’ git stash apply [apply a stashed change]
β’ git stash drop [remove a single stash entry]
5. πΉππππππ:
β’ git remote [manage a set of tracked repos]
β’ git remote add [add a remote with the name]
β’ git remote remove [remove the remote named <name>]
β’ git fetch [download from another repo]
β’ git pull [Fetch and merge (from remote/local)]
β’ git push [update remote (should pull first after a commit)]
β’ git clone β mirror[mirror source repo (maps all refs)]
6. πͺπππππππππππππ:
β’ git config [get and set options]
β’ git config β local [write in repoβs .git/config file (default)]
β’ git config β global [write in global ~/.gitconfig instead]
** To reset config, you need to check `git config β global β list` and call `git config β global β unset-all core.editor`
7. π·πππππππ:
β’ git cat-file [provide contents of repo]
β’ git checkout-index[copy files from the index to the working tree]
β’ git commit-tree [create a new commit object]
β’ git diff-tree [compares content and mode of blobs between two trees]
β’ git for-each-ref [information of each ref]
β’ git hash-object [compute object ID for an object]
β’ git ls-files [list directory tree]
β’ git ls-remote [list remote repo]
β’ git merge-tree [merge without touching index or working tree]
β’ git read-tree [read tree information into the index]
β’ git rev-parse [pick out and massage parameters]
β’ git show-branch [show branches and commits]
β’ git show-ref [list references in local repo]
β’ git symbolic-ref [read, modify and delete symbolic refs]
β’ git tag β list [list tags. With optional <pattern> for pattern-matching]
β’ git update-ref [update object name in ref]
8. π·ππππππππ:
β’ git blame [show revision and author for each line of file]
β’ git bisect [binary search to find bug starting to commit]
β’ git checkout [switch branches or restore working tree files]
β’ git commit [save the current state of file]]
β’ git rebase [reapply commits on top of another base tip]
β’ git reset [reset current HEAD to the specified state]
β’ git diff [view the changes]
β’ git fetch [download from another repo]
β’ git grep [print lines matching a pattern]
β’ git log [show commit logs]
β’ git merge [join two or more histories together]
β’ git push [update remote (should pull first after a commit)]
β’ git show [shows one or more objects (blobs, trees, tags and commits)]
β’ git tag [create, list, delete or verify a tag object signed with GPG]
9. π¨ππππ:
β’ git config β global alias.<alias> <command>
10. π―ππππ:
β’ git config β local core.hooksPath <path>
Git Official Documentation: πππππ://πππ-πππ.πππ/