This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Git rebase deleted file confusion repro

By: a guest on Aug 16th, 2012  |  syntax: None  |  size: 3.64 KB  |  views: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. $ ls -A
  2.  
  3. $ git init
  4. Initialized empty Git repository in /home/add/reproattempt/.git/
  5.  
  6. $ echo -e 'one\ntwo\nthree' | tee alpha | tee beta
  7. one
  8. two
  9. three
  10.  
  11. $ git add alpha beta
  12.  
  13. $ git commit -m 'Initial commit'
  14. [master (root-commit) e3f1056] Initial commit
  15.  2 files changed, 6 insertions(+), 0 deletions(-)
  16.  create mode 100644 alpha
  17.  create mode 100644 beta
  18.  
  19. $ git branch branch
  20.  
  21. $ git branch
  22.   branch
  23. * master
  24.  
  25. $ git rm alpha
  26. rm 'alpha'
  27.  
  28. $ git commit -m 'Deleted alpha'
  29. [master 5592048] Deleted alpha
  30.  1 files changed, 0 insertions(+), 3 deletions(-)
  31.  delete mode 100644 alpha
  32.  
  33. $ git checkout branch
  34. Switched to branch 'branch'
  35.  
  36. $ sed -i '/two/d' alpha
  37.  
  38. $ cat alpha
  39. one
  40. three
  41.  
  42. $ git commit -m 'Edit alpha' -- alpha
  43. [branch cda6327] Edit alpha
  44.  1 files changed, 0 insertions(+), 1 deletions(-)
  45.  
  46. $ git merge master
  47. CONFLICT (modify/delete): alpha deleted in master and modified in HEAD. Version HEAD of alpha left in tree.
  48. Automatic merge failed; fix conflicts and then commit the result.
  49.  
  50. $ git status
  51. # On branch branch
  52. # Unmerged paths:
  53. #   (use "git add/rm <file>..." as appropriate to mark resolution)
  54. #
  55. #       deleted by them:    alpha
  56. #
  57. no changes added to commit (use "git add" and/or "git commit -a")
  58.  
  59. $ git delete alpha
  60. git: 'delete' is not a git command. See 'git --help'.
  61.  
  62. $ git rm alpha
  63. alpha: needs merge
  64. rm 'alpha'
  65.  
  66. $ git status
  67. # On branch branch
  68. # Changes to be committed:
  69. #
  70. #       deleted:    alpha
  71. #
  72.  
  73. $ git commit  #Deleted the bits from the editor, but I just used the default message
  74. [branch 0fba33b] Merge branch 'master' into branch
  75.  
  76. $ git branch branch2
  77.  
  78. $ git log --graph --decorate --all
  79. *   commit 0fba33bbc2e995de7159cedcd04e86869f27c6cd (HEAD, branch2, branch)
  80. |\  Merge: cda6327 5592048
  81. | | Author: me_and
  82. | | Date:   Thu Aug 16 11:16:24 2012 +0100
  83. | |
  84. | |     Merge branch 'master' into branch
  85. | |
  86. | |     Conflicts:
  87. | |             alpha
  88. | |
  89. | * commit 5592048e7089cba2c2a88e05bf0b82a8de7e82e6 (master)
  90. | | Author: me_and
  91. | | Date:   Thu Aug 16 11:13:25 2012 +0100
  92. | |
  93. | |     Deleted alpha
  94. | |
  95. * | commit cda632752e266026a66f8f8433597e83e1d80e2b
  96. |/  Author: me_and
  97. |   Date:   Thu Aug 16 11:13:57 2012 +0100
  98. |
  99. |       Edit alpha
  100. |
  101. * commit e3f10566160bc81587833ea1e026f3e16f4d151a
  102.   Author: me_and
  103.   Date:   Thu Aug 16 11:12:55 2012 +0100
  104.  
  105.       Initial commit
  106.  
  107. $ git branch
  108. * branch
  109.   branch2
  110.   master
  111.  
  112. $ git rebase master
  113. First, rewinding head to replay your work on top of it...
  114. Applying: Edit alpha
  115. Using index info to reconstruct a base tree...
  116. Falling back to patching base and 3-way merge...
  117. Auto-merging beta
  118.  
  119. $ # Wait, what!? We're merging *beta*? That didn't change!
  120.  
  121. $ ls
  122. beta
  123.  
  124. $ cat beta
  125. one
  126. three
  127.  
  128. $ git checkout branch2
  129. Switched to branch 'branch2'
  130.  
  131. $ git rebase -i master  # Use the default message. That is "pick cda6327 Edit alpha"
  132.  
  133. error: could not apply cda6327... Edit alpha
  134.  
  135. When you have resolved this problem run "git rebase --continue".
  136. If you would prefer to skip this patch, instead run "git rebase --skip".
  137. To check out the original branch and stop rebasing run "git rebase --abort".
  138. Could not apply cda6327... Edit alpha
  139.  
  140. $ # Now that's more like what I'd expect!
  141.  
  142. $ git status
  143. # Not currently on any branch.
  144. # Unmerged paths:
  145. #   (use "git reset HEAD <file>..." to unstage)
  146. #   (use "git add/rm <file>..." as appropriate to mark resolution)
  147. #
  148. #       deleted by us:      alpha
  149. #
  150. no changes added to commit (use "git add" and/or "git commit -a")
  151.  
  152. $ git rm alpha
  153. alpha: needs merge
  154. rm 'alpha'
  155.  
  156. $ git rebase --continue
  157. Successfully rebased and updated refs/heads/branch2.
  158.  
  159. $ ls
  160. beta
  161.  
  162. $ cat beta
  163. one
  164. two
  165. three
clone this paste RAW Paste Data