Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The most obvious solution is to create two commits, and merge them. This is fairly safe, as once you get your changes into two different commits, it's fairly hard to lose them, and if the merge doesn't go as you want, you can throw away the merge commit and try again.</p> <p>For the first commit, you already have the changes staged, so just <code>git commit</code> should be sufficient.</p> <p>For the second, you have a state in your working copy that represents changes to the original <code>HEAD</code>. But now that you've done that commit, there's an intervening one; <code>HEAD</code> is what was in the index, so it looks like your working copy reverts those changes. To get around this, we need to reset where our <code>HEAD</code> points, without changing what's in the working copy.</p> <p>Before doing so, let's save a pointer to our current <code>HEAD</code>: <code>git branch was-in-index</code>. Now we can reset to the previous <code>HEAD</code> (the parent of <code>HEAD</code>) with <code>git reset HEAD^</code>, and add and commit our changes <code>git add some stuff; git commit</code> (or <code>git commit -a</code>, if you want all of your changes).</p> <p>Now we have two branches; our current one, which contains the changes from the working copy, and <code>was-in-index</code>, which contains the changes which were in the index. Now you can merge these however you want; <code>git merge was-in-index</code>, <code>git rebase was-in-index</code>, or what have you. You can delete the <code>was-in-index</code> branch when you're done.</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.
 

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