1 2 | |
git init : init directory as a git repogit clone [url] : clone repogit branch : list branchesgit checkout [branch] : switch branchgit checkout -b [branch] : create new branchgit checkout -d [branch] : delete branchgit checkout [commit] : switch branch to specific commitgit fetch : fetch changesgit pull : fetch + merge changesgit push : push changesgit push origin [branch] : push branchgit push --force origin [branch] : push branch after rebasegit add [file] : add changesgit add . : add all changesgit add -p : add changes interactivelygit commit -m "[message]" : commit changesgit status : status of local repogit diff [file a] [file b] : diff two files--cached : diff the added files-w : ignore whitespaces-b : ignore whitespaces at eol--ignore-cr-at-eol : ignore endlines--name-only : only list filesgit -c core.fileMode=false diff : diff two files, ignore file permissionsdifftasticgit rebase [src branch] : rebase current branch from another branchgit merge [branch] : merge branch into current branchgit cherry-pick [commit] : pull specific commitgit reset --soft [commit] : unstage commitgit reset --hard [commit] : undo commitgit checkout [file] : revert local change to a filegit reset --hard HEAD : revert all local changesgit reset --soft HEAD~1 : undo local commit, not pushed yetgit revert [commit] : create revert commitgit ... : undo remote commitgit reset --hard [commit]git push origin [branch] -fgit clean -xdf-n : dry run-x : ignore .gitignore-d : recursive-f : force-X : only ignored filesgif refloggit reset --hard [commit]1 2 | |
git stashsave "[message]" : stash current changeslist : show stashpop : pop stashdrop : drop stashapply stash@{0} : apply stashshow -p stash@{0} : show stash changesgit show -p stash@{0} > [patch file].patch : create patch from stashgit diff > [patch file].patch : create patch from unstaged changesgit diff --cached > [patch file].patch : create patch from staged changesgit apply [patch file].patch : apply patch filegit tag : list tagsgit tag [tag name] : add taggit push --tags : push tagsgit log : show changes log--stats : git reflog : show local repo historygit show [commit] : get info on commitgit blame -L [start line],[end line] [file] : find who last edited a file at specific linegit remote -v : list remotegit remote show origin : info on remotegit remote add [remote name] [remote url] : add remotegit remote set-url origin [remote url] : change remotegit checkout [commit]git bisect startgit bisect badgit bisect good [commit]git bisect bad/goodgit bisect resetgit clone --recursive : clone with submodulesgit submodule update --init --recursive : pull submodules after clonegit submodule add [submodule url] : add submodulegit rm [submodule]rm -rf .git/modules/[submodule]git config --remove-section submodule.[submodule]git commitgit lfs install : install LFS, once per usergit lfs track "*.[file type]" : add file type to track with LFSgit add .gitattributes : make sure that this is trackedcat ~/.gitconfig : show git config1 2 3 4 5 6 7 8 9 | |
git config --global pull.rebase true : always rebase on pullgit config --global core.autocrlf true : convert CRLF <-> LF (Windows)GitHub is no longer accepting account passwords, need to use PAT (Personal Access Token).
git config --global credential.helper store~/.git-credentials (plain text).git pull