Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>While <a href="https://stackoverflow.com/users/11343/charlesb">CharlesB's solution is correct and probably easier</a>, the reason that the original poster is seeing the commit message <strong><em>before</em></strong> the commit he wants to edit is because he's using the <code>--amend</code> flag of <code>git commit</code>, which modifies <strong><em>the previous</em></strong> commit.</p> <p>Instead of using <code>--amend</code> to commit your changes, just use <code>git commit</code> without the flag, which won't touch the previous commit. You can also pass in an option to reuse the commit message from the commit that you reset using <code>git reset head^</code>:</p> <pre class="lang-bash prettyprint-override"><code>git commit --reuse-message=HEAD@{1} # Or use -C, which is the same thing, but shorter: git commit -C HEAD@{1} </code></pre> <p><code>HEAD@{1}</code> points to the commit you were at before you did <code>git reset head^</code>. You can also just pass in the sha id for that commit directly.</p> <p>From <a href="https://www.kernel.org/pub/software/scm/git/docs/git-commit.html" rel="nofollow noreferrer">the <code>git commit</code> docs</a>:</p> <blockquote> <pre><code>-C &lt;commit&gt; --reuse-message=&lt;commit&gt; </code></pre> <p>Take an existing commit object, and reuse the log message and the authorship information (including the timestamp) when creating the commit.</p> </blockquote> <p>Of course, like I said, CharlesB's solution is simpler, since if you don't do the first <code>git reset head^</code>, you can just make changes and amend the commit you're trying to modify directly, and you automatically get the previous commit message when you do <code>git commit --amend</code>, you don't have to pass in the commit sha for it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload