/workbook/markdown/08-Everyday-Commands.md

http://github.com/matthewmccullough/git-workshop · Markdown · 84 lines · 47 code · 37 blank · 0 comment · 0 complexity · f48827a4499238e45bb7b61c1f752c2c MD5 · raw file

  1. # Everyday Commands
  2. ## Status
  3. Shows the current status of tracked objects in a repo while sitting anywhere in that repo's directory tree).
  4. git status
  5. Everything unstaged diffed to the last commit
  6. git diff
  7. Everything staged diffed to the last commit
  8. git diff --cached
  9. Everything unstaged and staged diffed to the last commit
  10. git diff HEAD
  11. ## Adding
  12. git add <WILDCARD>
  13. git add <SPECIFICFILENAME>
  14. Interactive
  15. git add -i
  16. Interactive patch mode
  17. git add --patch
  18. git add -p
  19. ## Removing
  20. Remove a file from being tracked
  21. git rm FILENAME
  22. ## Renaming (Moving)
  23. Rename a tracked file
  24. git mv FILENAME NEWFILENAME
  25. ## Committing
  26. Commit changes with a message provided interactively ($GIT_EDITOR or $EDITOR)
  27. git commit
  28. Or preview what would have occurred
  29. git commit --dry-run
  30. Commit with a message provided on the CLI
  31. git commit -m'Some message'
  32. Commit and add any modified tracked files in one unified command
  33. git commit -a
  34. ## Git Ignores
  35. Stored in a file at any level of the tree.
  36. .gitignore
  37. Can apply recursively.
  38. **/*.tmp
  39. Glob pattern format
  40. **/log*/*.log
  41. Exclusions
  42. !logstuffweneedtokeep
  43. ## Checkout to a different Branch
  44. Switch to a given branch
  45. git checkout BRANCHNAME
  46. Switch to a detached (arbitrary, detached) HEAD
  47. git checkout TREEISH