SHARE
TWEET

Untitled

a guest Oct 27th, 2015 110 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## Cloning a new repo from GitHub
  2.  
  3. ```
  4. $ git clone git@github.com:chrisroos/redolent-moo.git
  5. Cloning into 'redolent-moo'...
  6. remote: Counting objects: 3, done.
  7. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
  8. Receiving objects: 100% (3/3), done.
  9. Checking connectivity... done.
  10.  
  11. $ cd redolent-moo/
  12.  
  13. $ git reflog
  14. deaacb0 HEAD@{0}: clone: from git@github.com:chrisroos/redolent-moo.git
  15.  
  16. $ git reflog origin/master
  17. <No output>
  18. ```
  19.  
  20. ## Pushing a new commit to master
  21.  
  22. ```
  23. $ echo "Hello world" > hello-world.txt
  24.  
  25. $ git add .
  26.  
  27. $ git commit -m 'Add hello-world.txt'
  28. [master 6ee4e1d] Add hello-world.txt
  29.  1 file changed, 1 insertion(+)
  30.  create mode 100644 hello-world.txt
  31.  
  32. $ git push
  33. Counting objects: 3, done.
  34. Delta compression using up to 4 threads.
  35. Compressing objects: 100% (2/2), done.
  36. Writing objects: 100% (3/3), 302 bytes | 0 bytes/s, done.
  37. Total 3 (delta 0), reused 0 (delta 0)
  38. To git@github.com:chrisroos/redolent-moo.git
  39.    deaacb0..6ee4e1d  master -> master
  40.  
  41. $ git reflog
  42. 6ee4e1d HEAD@{0}: commit: Add hello-world.txt
  43. deaacb0 HEAD@{1}: clone: from git@github.com:chrisroos/redolent-moo.git
  44.  
  45. $ git reflog origin/master
  46. 6ee4e1d refs/remotes/origin/master@{0}: update by push
  47. deaacb0
  48. ```
  49.  
  50. ## Amending a commit and force-pushing to master
  51.  
  52. ```
  53. $ git commit --amend -m 'Update message for "Add hello-world.txt"'
  54. [master 91b1efb] Update message for "Add hello-world.txt"
  55.  Date: Tue Oct 27 14:59:19 2015 +0000
  56.  1 file changed, 1 insertion(+)
  57.  create mode 100644 hello-world.txt
  58.  
  59. $ git st
  60. On branch master
  61. Your branch and 'origin/master' have diverged,
  62. and have 1 and 1 different commit each, respectively.
  63.   (use "git pull" to merge the remote branch into yours)
  64. nothing to commit, working directory clean
  65.  
  66. $ git push
  67. To git@github.com:chrisroos/redolent-moo.git
  68.  ! [rejected]        master -> master (non-fast-forward)
  69. error: failed to push some refs to 'git@github.com:chrisroos/redolent-moo.git'
  70. hint: Updates were rejected because the tip of your current branch is behind
  71. hint: its remote counterpart. Integrate the remote changes (e.g.
  72. hint: 'git pull ...') before pushing again.
  73. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
  74.  
  75. $ git push -f
  76. Counting objects: 3, done.
  77. Delta compression using up to 4 threads.
  78. Compressing objects: 100% (2/2), done.
  79. Writing objects: 100% (3/3), 329 bytes | 0 bytes/s, done.
  80. Total 3 (delta 0), reused 0 (delta 0)
  81. To git@github.com:chrisroos/redolent-moo.git
  82.  + 6ee4e1d...91b1efb master -> master (forced update)
  83.  
  84. $ git reflog
  85. 91b1efb HEAD@{0}: commit (amend): Update message for "Add hello-world.txt"
  86. 6ee4e1d HEAD@{1}: commit: Add hello-world.txt
  87. deaacb0 HEAD@{2}: clone: from git@github.com:chrisroos/redolent-moo.git
  88.  
  89. $ git reflog origin/master
  90. 91b1efb refs/remotes/origin/master@{0}: update by push
  91. 6ee4e1d refs/remotes/origin/master@{1}: update by push
  92. deaacb0
  93. ```
  94.  
  95. ## Pulling from remote
  96.  
  97. ```
  98. $ git pull
  99. remote: Counting objects: 3, done.
  100. remote: Compressing objects: 100% (2/2), done.
  101. remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
  102. Unpacking objects: 100% (3/3), done.
  103. From github.com:chrisroos/redolent-moo
  104.    91b1efb..0bf0b52  master     -> origin/master
  105. Updating 91b1efb..0bf0b52
  106. Fast-forward
  107.  foo.txt | 1 +
  108.  1 file changed, 1 insertion(+)
  109.  create mode 100644 foo.txt
  110.  
  111. $ git reflog
  112. 0bf0b52 HEAD@{0}: pull: Fast-forward
  113. 91b1efb HEAD@{1}: clone: from git@github.com:chrisroos/redolent-moo.git
  114.  
  115. $ git reflog origin/master
  116. 0bf0b52 refs/remotes/origin/master@{0}: pull: fast-forward
  117. 91b1efb
  118. ```
  119.  
  120. ## Pulling from remote that's been force-pushed
  121.  
  122. ```
  123. $ git fetch origin
  124. remote: Counting objects: 3, done.
  125. remote: Compressing objects: 100% (2/2), done.
  126. remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
  127. Unpacking objects: 100% (3/3), done.
  128. From github.com:chrisroos/redolent-moo
  129.  + 0bf0b52...8021f75 master     -> origin/master  (forced update)
  130.  
  131. $ git st
  132. On branch master
  133. Your branch and 'origin/master' have diverged,
  134. and have 1 and 1 different commit each, respectively.
  135.   (use "git pull" to merge the remote branch into yours)
  136. nothing to commit, working directory clean
  137.  
  138. $ git reflog
  139. 0bf0b52 HEAD@{0}: pull: Fast-forward
  140. 91b1efb HEAD@{1}: clone: from git@github.com:chrisroos/redolent-moo.git
  141.  
  142. $ git reflog origin/master
  143. 8021f75 refs/remotes/origin/master@{0}: fetch origin: forced-update
  144. 0bf0b52 refs/remotes/origin/master@{1}: pull: fast-forward
  145. 91b1efb
  146. ```
  147.  
  148. ## Merging from remote
  149.  
  150. ```
  151. $ git fetch
  152. remote: Counting objects: 3, done.
  153. remote: Compressing objects: 100% (1/1), done.
  154. remote: Total 3 (delta 1), reused 3 (delta 1), pack-reused 0
  155. Unpacking objects: 100% (3/3), done.
  156. From github.com:chrisroos/redolent-moo
  157.    5edd749..73f3bd5  master     -> origin/master
  158.  
  159. $ git merge --no-commit origin/master
  160. Updating 5edd749..73f3bd5
  161. Fast-forward
  162.  baz.txt | 1 +
  163.  1 file changed, 1 insertion(+)
  164.  create mode 100644 baz.txt
  165.  
  166. $ git reflog
  167. 73f3bd5 HEAD@{0}: merge origin/master: Fast-forward
  168. 5edd749 HEAD@{1}: pull: Fast-forward
  169. 8021f75 HEAD@{2}: reset: moving to origin/master
  170. 0bf0b52 HEAD@{3}: pull: Fast-forward
  171. 91b1efb HEAD@{4}: clone: from git@github.com:chrisroos/redolent-moo.git
  172.  
  173. $ git reflog origin/master
  174. 73f3bd5 refs/remotes/origin/master@{0}: fetch: fast-forward
  175. 5edd749 refs/remotes/origin/master@{1}: pull: fast-forward
  176. 8021f75 refs/remotes/origin/master@{2}: fetch origin: forced-update
  177. 0bf0b52 refs/remotes/origin/master@{3}: pull: fast-forward
  178. 91b1efb
  179. ```
  180.  
  181. ## Merging from remote that's been force-pushed
  182.  
  183. ```
  184. $ git fetch
  185. remote: Counting objects: 3, done.
  186. remote: Compressing objects: 100% (1/1), done.
  187. remote: Total 3 (delta 1), reused 3 (delta 1), pack-reused 0
  188. Unpacking objects: 100% (3/3), done.
  189. From github.com:chrisroos/redolent-moo
  190.  + 142a9df...b29b159 master     -> origin/master  (forced update)
  191.  
  192. $ git merge --no-commit origin/master
  193. Automatic merge went well; stopped before committing as requested
  194.  
  195. $ git st
  196. On branch master
  197. Your branch and 'origin/master' have diverged,
  198. and have 1 and 1 different commit each, respectively.
  199.   (use "git pull" to merge the remote branch into yours)
  200. All conflicts fixed but you are still merging.
  201.   (use "git commit" to conclude merge)
  202.  
  203. nothing to commit, working directory clean
  204.  
  205. $ git reflog
  206. 142a9df HEAD@{0}: merge origin/master: Fast-forward
  207.  
  208. $ git reflog origin/master
  209. b29b159 refs/remotes/origin/master@{0}: fetch: forced-update
  210. 142a9df refs/remotes/origin/master@{1}: fetch: fast-forward
  211.  
  212. $ git commit -m 'Merge foo'
  213. [master 1deaf0c] Merge foo
  214.  
  215. $ git reflog
  216. 1deaf0c HEAD@{0}: commit (merge): Merge foo
  217. 142a9df HEAD@{0}: merge origin/master: Fast-forward
  218.  
  219. $ git reflog origin/master
  220. b29b159 refs/remotes/origin/master@{0}: fetch: forced-update
  221. 142a9df refs/remotes/origin/master@{1}: fetch: fast-forward
  222. ```
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top