Amend a past commit from a previously merged branch, while keeping branch history
<h1>Problem</h1>

<p>Say that I have done some work on <code>master</code>:</p>

<pre><code>c1 &lt;- c2
       ^
     master
</code></pre>

<p>At this point, I branch off, and do some more work:</p>

<pre><code>                test                  
                 v
          c3 &lt;- c4
c1 &lt;- c2 /
       ^   
     master
</code></pre>

<p>Then do a <code>git merge --no-ff</code> (<code>--no-ff</code> to keep the branch history):</p>

<pre><code>                test                  
                 v
          c3 &lt;- c4
c1 &lt;- c2 /        \ [c5]
                      ^   
                    master
</code></pre>

<p>(<code>[c5]</code> is a merge commit)</p>

<p>I then delete the <code>test</code> branch, thinking that I have finished with it. However, I find that, after all, there is a problem with the work I've done on <code>test</code>. I need to amend <code>c3</code>, but <strong>without harming the branch history.</strong></p>

<hr>

<h1>Things that I've tried</h1>

<p><br></p>

<h2>My attempt</h2>

<p>I <code>git checkout c3</code>; then change what I need to change, and then <code>git commit --amend</code>. Then I <code>checkout</code> the <code>master</code> branch, and <code>git branch temp c3</code>. I then <code>git rebase --preserve-merges temp</code>: this gives me a merge conflict, which I fix, and then <code>git add &lt;file&gt;</code> and <code>git rebase --continue</code>. </p>

<p>However, when I look at the branch history with <code>git log --oneline --graph</code>, I see something like the following:</p>

<pre><code>*  [c5]
|\
| * c4
|/
* c3'
* c2
* c1
</code></pre>

<p>It should look more like this:</p>

<pre><code>*  [c5]
|\
| * c4
| * c3'
|/
* c2
* c1
</code></pre>

<p>where <code>c3'</code> is the amended commit.</p>

<p>How can I get this behaviour out of <code>git</code>? 
<br></p>

<h2>Tim's suggestion</h2>

<pre><code>git checkout c3
git checkout -b test
git commit --amend
git checkout master
git reset --hard c2
git merge --no-ff test
</code></pre>

<p>Unfortunately, this doesn't seem to work, as we lose <code>c4</code>. (Please correct me, Tim, if I'm misinterpreting your answer.) The resulting branch history from <code>git log --oneline --graph</code> is as follows:</p>

<pre><code>*  [c5]
|\  
| * c3'
|/  
* c2
* c1
</code></pre>

<p>where <code>[c5']</code> is a new merge commit. (I don't mind that it's new, by the way.)</p>