title: git rebase -i -autosquash conflict
body: <p>git is giving me a major headache when using --fixup and --autosquash. 
  I would like to give two examples, one working perfectly fine and the other being a mess. (git version 2.6.2)</p>
  
  <p><strong>Working example:</strong></p>
  
  <p><em>First commit:</em></p>
  
  <pre><code>$ git init
  $ printf '1\n' &gt; test.file
  $ git add test.file
  $ git commit -m 'Insert 1 --&gt; first line'  
  $ cat test.file
  1
  </code></pre>
  
  <p><em>Second commit (BUG):</em></p>
  
  <pre><code>$ printf 'This is\na BUG\n' &gt;&gt; test.file
  $ git commit -am 'Added line 2 and 3 with BUG'
  $ cat test.file
  1  
  This is  
  a BUG
  </code></pre>
  
  <p><em>Third commit:</em></p>
  
  <pre><code>$ sed -i '2i 2' test.file
  $ git commit -am 'Insert 2 --&gt; second line'
  $ cat test.file
  1  
  2  
  This is  
  a BUG
  </code></pre>
  
  <p><em>Fourth commit (fixup):</em></p>
  
  <pre><code>$ sed -i 's/a BUG/NOT a BUG/' test.file
  $ git add test.file
  $ git log --oneline
  b021696 Insert 2 --&gt; second line  
  2e18b8d Added line 2 and 3 with BUG  
  d7b60a1 Insert 1 --&gt; first line  
  $ git commit --fixup HEAD~
  $ cat test.file
  1  
  2  
  This is  
  NOT a BUG
  </code></pre>
  
  <p><em>Rebase:</em></p>
  
  <pre><code>$ git log --oneline
  fe99989 fixup! Added line 2 and 3 with BUG  
  b021696 Insert 2 --&gt; second line  
  2e18b8d Added line 2 and 3 with BUG  
  d7b60a1 Insert 1 --&gt; first line
  
  $ git rebase -i --autosquash HEAD~3
  
  [detached HEAD 6660b0e] Added line 2 and 3 with BUG
  Date: Tue Nov 3 13:28:07 2015 +0100
  1 file changed, 2 insertions(+)
  Successfully rebased and updated refs/heads/master.
  </code></pre>
  
  <hr>
  
  <p><strong>Headache example:</strong> (Only difference is the BUGGY commit is a single line)</p>
  
  <p><em>First commit:</em></p>
  
  <pre><code>$ git init
  $ printf '1\n' &gt; test.file
  $ git add test.file
  $ git commit -m 'Insert 1 --&gt; first line'  
  $ cat test.file
  1
  </code></pre>
  
  <p><em>Second commit (BUG):</em></p>
  
  <pre><code>$ printf 'This is a BUG\n' &gt;&gt; test.file
  $ git commit -am 'Added line 2 with BUG'
  $ cat test.file
  1
  This is a BUG
  </code></pre>
  
  <p><em>Third commit:</em></p>
  
  <pre><code>$ sed -i '2i 2' test.file
  $ git commit -am 'Insert 2 --&gt; second line'
  $ cat test.file
  1  
  2  
  This is a BUG
  </code></pre>
  
  <p><em>Fourth commit (fixup):</em></p>
  
  <pre><code>$ sed -i 's/a BUG/NOT a BUG/' test.file
  $ git add test.file
  $ git log --oneline
  2b83fe7 Insert 2 --&gt; second line  
  62cdd05 Added line 2 with BUG  
  0ee3343 Insert 1 --&gt; first line
  $ git commit --fixup HEAD~
  $ cat test.file
  1  
  2  
  This is NOT a BUG
  </code></pre>
  
  <p><em>Rebase:</em> </p>
  
  <pre><code>$ git log --oneline
  c3d3db7 fixup! Added line 2 with BUG  
  2b83fe7 Insert 2 --&gt; second line  
  62cdd05 Added line 2 with BUG  
  0ee3343 Insert 1 --&gt; first line
  $ git rebase -i --autosquash HEAD~3
  error: could not apply c3d3db7... fixup! Added line 2 with BUG
  
  When you have resolved this problem, run "git rebase --continue".
  If you prefer to skip this patch, run "git rebase --skip" instead.
  To check out the original branch and stop rebasing, run "git rebase --abort".
  
  Could not apply c3d3db78440e48c1bb637f78e0767520db65ea1e... fixup! Added line 2 with BUG
  
  $ git status
  interactive rebase in progress; onto 0ee3343
  Last commands done (2 commands done):
     pick 62cdd05 Added line 2 with BUG
     fixup c3d3db7 fixup! Added line 2 with BUG
  Next command to do (1 remaining command):
     pick 2b83fe7 Insert 2 --&gt; second line
    (use "git rebase --edit-todo" to view and edit)
  You are currently rebasing branch 'master' on '0ee3343'.
    (fix conflicts and then run "git rebase --continue")
    (use "git rebase --skip" to skip this patch)
    (use "git rebase --abort" to check out the original branch)
  
  Unmerged paths:
    (use "git reset HEAD &lt;file&gt;..." to unstage)
    (use "git add &lt;file&gt;..." to mark resolution)
  
          both modified:   test.file
  
  no changes added to commit (use "git add" and/or "git commit -a")  
  
  $ cat test.file
  1 
  &lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD
  This is a BUG
  ======= 
  2 
  This is NOT a BUG
  &gt;&gt;&gt;&gt;&gt;&gt;&gt; c3d3db7... fixup! Added line 2 with BUG
  </code></pre>
  
  <hr>
  
  <p>Why does the fixup not apply cleanly? </p>
  
  <p>Why does the fixup also contain "2" which should not be in the patch introduced by the fixup but in the patch of the former commit.</p>