Guest User

Untitled

a guest
Mar 23rd, 2018
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. ## Configure
  2.  
  3. Notes | Git commands
  4. ------|-------------------
  5. Configure the author name to be used with your commits | `git config --global user.name "Sam Smith"`
  6. Configure the email address to be used with your commits | `git config --global user.email sam@example.com`
  7.  
  8. ## Init
  9.  
  10. Notes | Git commands
  11. ------|-------------------
  12. Create a new local repository | `git init`
  13.  
  14. ## Clone
  15.  
  16. Notes | Git commands
  17. ------|-------------------
  18. Create a working copy of a local repository | `git clone /path/to/repository`
  19. For a remote server | `git clone username@host:/path/to/repository`
  20.  
  21. ## Status
  22.  
  23. Notes | Git commands
  24. ------|-------------------
  25. List the files you've changed and those you still need to add or commit | `git status`
  26.  
  27. ## Add to staging (index)
  28.  
  29. Notes | Git commands
  30. ------|-------------------
  31. Add one files to staging (index) | `git add <filename>`
  32. Add more files to staging | `git add .`
  33.  
  34. ## Commit
  35.  
  36. Notes | Git commands
  37. ------|-------------------
  38. Commit changes to head (but not yet to the remote repository) | `git commit -m "Commit message"`
  39. Commit any files you've added with git add, and also commit any files you've changed since then | `git commit -a`
  40.  
  41. ## Remote repository
  42.  
  43. Notes | Git commands
  44. ------|-------------------
  45. Connect to a remote repository | `git remote add origin <server>`
  46. List all currently configured remote repositories | `git remote -v`
  47.  
  48. ## Checkout
  49.  
  50. Notes | Git commands
  51. ------|-------------------
  52. Create a new branch and switch to it | `git checkout -b <branchname>`
  53. Switch from one branch to another | `git checkout <branchname>`
  54.  
  55. ## Branches
  56.  
  57. Notes | Git commands
  58. ------|-------------------
  59. List all the branches in your repo, and also tell you what branch you're currently in | `git branch`
  60. Delete the feature branch | `git branch -d <branchname>`
  61.  
  62. ## Push
  63.  
  64. Notes | Git commands
  65. ------|-------------------
  66. Send changes to the master branch of your remote repository | `git push origin master`
  67. Push the branch to your remote repository, so others can use it: | `git push origin <branchname>`
  68. Delete a branch on your remote repository | `git push origin <branchname>`
  69. Push all branches to your remote repository | `git push --all origin`
  70. Push all tags to remote repository | `git push --tags origin`
  71.  
  72. ## Pull
  73.  
  74. Notes | Git commands
  75. ------|-------------------
  76. Update from the remote repository Fetch and merge changes on the remote server to your working directory | `git pull`
  77.  
  78. ## Merge
  79.  
  80. Notes | Git commands
  81. ------|-------------------
  82. To merge a different branch into your active branch | `git merge <branchname>`
  83.  
  84. ## Different
  85.  
  86. Notes | Git commands
  87. ------|-------------------
  88. View all the merge conflicts | `git diff`
  89. View the conflicts against the base file | `git diff --base <filename>`
  90. Preview changes, before merging | `git diff <sourcebranch> <targetbranch>`
  91.  
  92. ## Tags
  93.  
  94. Notes | Git commands
  95. ------|-------------------
  96. Tags You can use tagging to mark a significant changeset, such as a release | `git tag 1.0.0 <commitID>``
  97.  
  98. ## Log
  99.  
  100. Notes | Git commands
  101. ------|-------------------
  102. CommitId is the leading characters of the changeset ID, up to 10, but must be unique | `git log`
  103.  
  104. ## Undo changes
  105.  
  106. Notes | Git commands
  107. ------|-------------------
  108. Undo local changes. You can replace the changes in your working tree with the last content in head | `git checkout -- <filename>`
  109. Instead, to drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it, do this | `git reset --hard origin/master`
  110. Remove the last commit keeping changes | `git reset HEAD~1`
  111.  
  112. ## Stash
  113.  
  114. Notes | Git commands
  115. ------|-------------------
  116. Stash list | `git stash list`
  117. List the changes in <stash> | `git stash show <stash>`
  118. Save working directory and index state | `git stash`
  119. Apply the changes in branch actual | `git stash (pop/apply) <stash>`
  120. Drop the stash | `git stash drop <stash>`
Add Comment
Please, Sign In to add comment