====== Git Quick Reference Card ======
Git cheat sheet.
Full [[https://git-scm.com/docs|documentation]].
===== Add, commit & push =====
git status
git add -A
git commit -m "JD - commit server work"
git pull origin master
git push origin master
To provide a detailed message and description from the command line: ''git commit''.
Then ''Insert'' key. Commented ''#'' lines are ignored. First line is the summary; subsequent lines are the detailed description.
Then ''ESC'' key. Close the editor with '':wq'' (w - write, q - quit) and ''Enter'' key.
[[https://stackoverflow.com/questions/16122234/how-to-commit-a-change-with-both-message-and-description-from-the-command-li|source]]
===== Variations =====
See modifications within the current directory.
git status .
Recursively add files in working directory and subdirectories (new, modified, deleted).
git add -A .
Push with force. Use with caution.
git push --force origin master
Pull with forced overwrite [[https://stackoverflow.com/questions/1125968/how-do-i-force-git-pull-to-overwrite-local-files|link]]:
git fetch --all
git reset --hard origin/master
===== Stash =====
git stash
Records the current state of the working directory. This command saves your local modifications away and reverts the working directory to match the HEAD commit.
[[https://stackoverflow.com/questions/1260748/how-do-i-remove-a-submodule|How to remove a submodule]]
===== Checkout =====
Reset file foo to HEAD. Stackoverflow [[https://stackoverflow.com/questions/215718/how-can-i-reset-or-revert-a-file-to-a-specific-revision|link1]]
git checkout -- foo