Advertisement
ShaunDreclin

Githelp.txt

Apr 22nd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. • Stuff in ALL_CAPS needs to be filled in.
  2. • Never work in your master branch, it should always be a copy of upstream/master
  3. • Branch names are generally all-lowercase-with-dashes-between-words
  4. • Commit messages should use present-tense imperative verbs. (Change, not Changed)
  5.  
  6. ------------
  7.  
  8. Download a repo from github to work on it locally (From parent folder)
  9. You want to download *your* repo that you forked from the main project.
  10. git clone https://github.com/SOME_PERSON/SOME_PROJECT.git
  11. git clone https://github.com/YOUR_USERNAME/runelite.git
  12.  
  13. Add remote (You should add the main project as a remote)
  14. git remote add REMOTE_NAME https://github.com/SOME_PERSON/SOME_PROJECT.git
  15. git remote add upstream https://github.com/runelite/runelite.git
  16.  
  17. Rename remote
  18. git remote rename OLD_REMOTE_NAME NEW_REMOTE_NAME
  19.  
  20. Check remotes
  21. git remote -v
  22.  
  23. Check remote branches
  24. git branch -r
  25.  
  26. Delete remote
  27. git remote rm REMOTE_NAME
  28.  
  29. ------------
  30.  
  31. Create a new branch (will copy from your current branch)
  32. git checkout -b BRANCH_NAME
  33.  
  34. Change current branch
  35. git checkout BRANCH_NAME
  36.  
  37. Check branches
  38. git branch -v
  39.  
  40. Delete remote branch
  41. git push -d REMOTE_NAME BRANCH_NAME
  42.  
  43. Delete local branch
  44. git branch -d BRANCH_NAME
  45.  
  46. ------------
  47.  
  48. Check the status of the current branch.
  49. Files modified/added/removed will be in red, files in the staging area in green
  50. git status
  51.  
  52. Check the difference between modified files and your last commit
  53. git diff --ignore-space-at-eol (ignores changes in line break type)
  54. git diff
  55.  
  56. Add a modified/added/removed file to the staging area
  57. git add FILE_NAME.txt
  58. git add *.txt
  59.  
  60. Remove a modified/added/removed file from the staging area
  61. git reset FILE_NAME.txt
  62.  
  63. Add ALL modified/added/removed to the staging area (Capital A required)
  64. git add -A
  65.  
  66. Commit with a descriptive message saying what you did
  67. git commit -m "COMMIT_MESSAGE"
  68.  
  69. ------------
  70.  
  71. Push branch to github
  72. git push remotename branchname
  73.  
  74. Pull branch from github
  75. git pull remotename branchname
  76.  
  77. ------------
  78.  
  79. Fetch branches from remote (do this before rebasing)
  80. git fetch REMOTE_NAME
  81. git fetch upstream
  82.  
  83. Switch to master branch
  84. git checkout master
  85.  
  86. Rebase changes from upstream to local copy
  87. git rebase REMOTE_NAME/BRANCH_NAME
  88. git rebase upstream/master
  89.  
  90. Switch to feature/working branch
  91. git checkout BRANCH_NAME
  92.  
  93. Rebase local branch from local master branch
  94. git rebase BRANCH_NAME
  95. git rebase master
  96.  
  97. If there are merge conflicts, open the conflicting file in a text
  98. editor and decide between the lines above or below the ===== line
  99. then do:
  100. git add FILE_NAME.txt
  101. git rebase --continue
  102.  
  103. ------------
  104.  
  105. Make git not use a pager for long results
  106. git config core.pager cat
  107.  
  108. ------------
  109.  
  110. Add somebody else's fork as a remote
  111. git remote add sethtroll https://github.com/sethtroll/runelite.git
  112. git fetch sethtroll
  113. git merge --no-edit sethtroll/addshiftclicktag
  114.  
  115. ------------
  116.  
  117. See last 5 commits
  118. git log -n 5
  119.  
  120. Show info about a certain commit id
  121. git show COMMIT_ID
  122.  
  123. Interactive rebase (for editing history)
  124. git rebase --interactive PARENT_OF_FLAWED_COMMIT_ID
  125.  
  126. Get count of of commits behind and ahead (respectively) of master
  127. git rev-list --left-right --count master...BRANCH_NAME
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement