Advertisement
gusto2

git cheat-sheet

Dec 21st, 2016
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. original: http://files.zeroturnaround.com/pdf/zt_git_cheat_sheet.pdf
  2.  
  3. Create a Repository
  4. From scratch -- Create a new local
  5. repository
  6. $ git init [project name]
  7. Download from an existing repository
  8. $ git clone my_url
  9. Make a change Synchronize
  10. Observe your Repository
  11. List new or modified files not yet
  12. committed
  13. $ git status
  14. Show the changes to files not yet staged
  15. $ git diff
  16. Show the changes to staged files
  17. $ git diff --cached
  18. Show all staged and unstaged
  19. file changes
  20. $ git diff HEAD
  21. Show the changes between two
  22. commit ids
  23. $ git diff commit1 commit2
  24. List the change dates and authors
  25. for a file
  26. $ git blame [file]
  27. Show the file changes for a commit
  28. id and/or file
  29. $ git show [commit]:[file]
  30. Show full change history
  31. $ git log
  32. Show change history for file/directory
  33. including diffs
  34. $ git log -p [file/directory]
  35. Stages the file, ready for commit
  36. $ git add [file]
  37. Stage all changed files, ready for commit
  38. $ git add .
  39. Commit all staged files to versioned history
  40. $ git commit -m “commit message”
  41. Commit all your tracked files to
  42. versioned history
  43. $git commit -am “commit message”
  44. Unstages file, keeping the file changes
  45. $ git reset [file]
  46. Revert everything to the last commit
  47. $ git reset --hard
  48. Get the latest changes from origin
  49. (no merge)
  50. $ git fetch
  51. Fetch the latest changes from origin
  52. and merge
  53. $ git pull
  54. Fetch the latest changes from origin
  55. and rebase
  56. $ git pull --rebase
  57. Push local changes to the origin
  58. $ git push
  59. Working with Branches
  60. List all local branches
  61. $ git branch
  62. List all branches, local and remote
  63. $ git branch -av
  64. Switch to a branch, my_branch,
  65. and update working directory
  66. $ git checkout my_branch
  67. Create a new branch called new_branch
  68. $ git branch new_branch
  69. Delete the branch called my_branch
  70. $ git branch -d my_branch
  71. Merge branch_a into branch_b
  72. $ git checkout branch_b
  73. $ git merge branch_a
  74. Tag the current commit
  75. $ git tag my_tag
  76. Finally!
  77. When in doubt, use git help
  78. $ git command --help
  79. Or visit https://training.github.com/
  80. for official GitHub training.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement