Advertisement
GarbageYard

Git Reset Issue

Mar 23rd, 2015
552
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.61 KB | None | 0 0
  1. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Developer John committed some changes
  3.  
  4. After John pushed changes to central server, developer Roger did the following:
  5.  
  6. roger@work ~some_repo (some_branch)
  7. $ git pull origin <some_branch>
  8. From ssh://git.server:2400/some_repo
  9. * branch some_branch -> FETCH_HEAD
  10. Auto-merging sample.sh
  11. CONFLICT (content): Merge conflict in sample.sh
  12. Automatic merge failed; fix conflicts and then commit the result.
  13.  
  14.  
  15. roger@work ~some_repo (some_branch|MERGING)
  16. $ git status
  17. # On branch some_branch
  18. # Your branch is ahead of 'origin/some_branch' by 2 commit.
  19. # (use "git push" to publish your local commits)
  20. #
  21. # You have unmerged paths.
  22. # (fix conflicts and run "git commit")
  23. #
  24. # Unmerged paths:
  25. # (use "git add <file>..." to mark resolution)
  26. #
  27. # both modified: sample.sh
  28. ...
  29. ...
  30. ...
  31.  
  32.  
  33. roger@work ~some_repo (some_branch|MERGING)
  34. $ git reset .
  35. Unstaged changes after reset
  36. M sample.sh
  37.  
  38.  
  39. roger@work ~some_repo (some_branch|MERGING)
  40. $ git checkout .
  41.  
  42.  
  43. roger@work ~some_repo (some_branch|MERGING)
  44. $ git status
  45. # On branch some_branch
  46. # Your branch is ahead of 'origin/some_branch' by 2 commit.
  47. # (use "git push" to publish your local commits)
  48. #
  49. # All conflicts fixed but you are still merging.
  50. # (use "git commit" to conclude merge)
  51. # Changes not staged for commit:
  52. # (use "git add <file>..." to update what will be committed)
  53. # (use "git checkout -- <file>..." to discard changes in working directory)
  54. #
  55. # modified: sample.sh
  56. #
  57. # no changes added to commit (use "git add" and/or "git commit -a")
  58.  
  59.  
  60. roger@work ~some_repo (some_branch|MERGING)
  61. $ git add sample.sh
  62.  
  63.  
  64. roger@work ~some_repo (some_branch|MERGING)
  65. $ git commit -m "JIRA_ID-33065"
  66.  
  67.  
  68. roger@work ~some_repo (some_branch|MERGING)
  69. $ git push origin some_branch
  70. Counting objects: 59, done.
  71. Delta compression using...
  72. ...
  73. ...
  74. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  75. Now i tried simulating the above scenario by creating two users (tom and harry) in Gitolite but could not succeed.
  76.  
  77. 1. User A modified, committed and pushed changes in a file (startServer.sh).
  78.  
  79. tom@lappyA /d/git/some_branch (some_branch)
  80. $ vim startServer.sh
  81.  
  82. tom@lappyA /d/git/some_branch (some_branch)
  83. $ git add startServer.sh
  84.  
  85. tom@lappyA /d/git/some_branch (some_branch)
  86. $ git commit -m "JIRA_ID-33065: Added dot to startServer.sh script"
  87.  
  88. tom@lappyA /d/git/some_branch (some_branch)
  89. $ git push origin some_branch
  90.  
  91.  
  92. 2. After Tom pushed the above changes, Harry did not perform any pull on his machine. He instead modified the same file and the same line which Tom did. Harry then committed the changes. Harry, when tried pushing his changes, got some different message than the one which the original developer (in this case, Roger) got. Besides working on a common file (startServer.sh), Harry also wanted to check-in another file (stopServer.sh) which Tom did not change.
  93.  
  94. [harry@master some_branch]$ vim startServer.sh
  95.  
  96.  
  97. [harry@master some_branch]$ git add startServer.sh
  98.  
  99.  
  100. [harry@master some_branch]$ git commit -m "JIRA_ID-1234: Added 5 dots in startServer"
  101. [some_branch d97664e] JIRA_ID-1234: Added 5 dots in startServer
  102. 1 file changed, 1 insertion(+), 1 deletion(-)
  103.  
  104.  
  105. [harry@master some_branch]$ git pull origin some_branch
  106. From ssh://git.server:2400/some_branch
  107. * branch some_branch -> FETCH_HEAD
  108. Auto-merging startServer.sh
  109. CONFLICT (content): Merge conflict in startServer.sh
  110. Automatic merge failed; fix conflicts and then commit the result.
  111.  
  112.  
  113. [harry@master some_branch]$ git status
  114. On branch some_branch
  115. Your branch and 'origin/some_branch' have diverged,
  116. and have 1 and 1 different commit each, respectively.
  117. (use "git pull" to merge the remote branch into yours)
  118. You have unmerged paths.
  119. (fix conflicts and run "git commit")
  120.  
  121. Unmerged paths:
  122. (use "git add <file>..." to mark resolution)
  123.  
  124. both modified: startServer.sh
  125.  
  126. no changes added to commit (use "git add" and/or "git commit -a")
  127.  
  128.  
  129. [harry@master some_branch]$ git reset .
  130. Unstaged changes after reset:
  131. M startServer.sh
  132.  
  133.  
  134. [harry@master some_branch]$ git status
  135. On branch some_branch
  136. Your branch and 'origin/some_branch' have diverged,
  137. and have 1 and 1 different commit each, respectively.
  138. (use "git pull" to merge the remote branch into yours)
  139. All conflicts fixed but you are still merging.
  140. (use "git commit" to conclude merge)
  141.  
  142. Changes not staged for commit:
  143. (use "git add <file>..." to update what will be committed)
  144. (use "git checkout -- <file>..." to discard changes in working directory)
  145.  
  146. modified: startServer.sh
  147.  
  148. no changes added to commit (use "git add" and/or "git commit -a")
  149.  
  150.  
  151. [harry@master some_branch]$ git checkout .
  152.  
  153.  
  154. [harry@master some_branch]$ git status
  155. On branch some_branch
  156. Your branch and 'origin/some_branch' have diverged,
  157. and have 1 and 1 different commit each, respectively.
  158. (use "git pull" to merge the remote branch into yours)
  159. All conflicts fixed but you are still merging.
  160. (use "git commit" to conclude merge)
  161.  
  162. nothing to commit, working directory clean
  163.  
  164.  
  165. [harry@master some_branch]$ vim stopServer.sh
  166.  
  167.  
  168. [harry@master some_branch]$ git status
  169. On branch some_branch
  170. Your branch and 'origin/some_branch' have diverged,
  171. and have 1 and 1 different commit each, respectively.
  172. (use "git pull" to merge the remote branch into yours)
  173. All conflicts fixed but you are still merging.
  174. (use "git commit" to conclude merge)
  175.  
  176. Changes not staged for commit:
  177. (use "git add <file>..." to update what will be committed)
  178. (use "git checkout -- <file>..." to discard changes in working directory)
  179.  
  180. modified: stopServer.sh
  181.  
  182. no changes added to commit (use "git add" and/or "git commit -a")
  183.  
  184. [harry@master some_branch]$ git add stopServer.sh
  185.  
  186.  
  187. [harry@master some_branch]$ git commit -m "JIRA_ID-1234: Removed dots from script"
  188. [some_branch a13330a] JIRA_ID-1234: Removed dots from script
  189.  
  190.  
  191. [harry@master some_branch]$ git push origin some_branch
  192. Counting objects: 5, done.
  193. Delta compression using up to 2 threads.
  194. Compressing objects: 100% (5/5), done.
  195. Writing objects: 100% (5/5), 627 bytes | 0 bytes/s, done.
  196. Total 5 (delta 3), reused 0 (delta 0)
  197. remote: As it is a merge no need to do any validation
  198. remote: To gitolite@release_team_essentials:some_branch.git
  199. remote: b44fd4e..a13330a some_branch -> some_branch
  200. To ssh://gitolite@git.server:2400/some_branch
  201. b44fd4e..a13330a some_branch -> some_branch
  202. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement