Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can use <code>git add --patch &lt;filename&gt;</code> (or <code>-p</code> for short), and git will begin to break down your file into what it thinks are sensible "hunks" (portions of the file). It will then prompt you with this question:</p> <pre><code>Stage this hunk [y,n,q,a,d,/,j,J,g,s,e,?]? </code></pre> <p>Here is a description of each option:</p> <ul> <li><kbd>y</kbd> stage this hunk for the next commit</li> <li><kbd>n</kbd> do not stage this hunk for the next commit</li> <li><kbd>q</kbd> quit; do not stage this hunk or any of the remaining hunks</li> <li><kbd>a</kbd> stage this hunk and all later hunks in the file</li> <li><kbd>d</kbd> do not stage this hunk or any of the later hunks in the file</li> <li><kbd>g</kbd> select a hunk to go to</li> <li><kbd>/</kbd> search for a hunk matching the given regex</li> <li><kbd>j</kbd> leave this hunk undecided, see next undecided hunk</li> <li><kbd>J</kbd> leave this hunk undecided, see next hunk</li> <li><kbd>k</kbd> leave this hunk undecided, see previous undecided hunk</li> <li><kbd>K</kbd> leave this hunk undecided, see previous hunk</li> <li><kbd>s</kbd> split the current hunk into smaller hunks</li> <li><kbd>e</kbd> manually edit the current hunk</li> <li><kbd>?</kbd> print hunk help</li> </ul> <p>If the file is not in the repository yet, you can first do <code>git add -N &lt;filename&gt;</code>. Afterwards you can go on with <code>git add -p &lt;filename&gt;</code>.</p> <p>Afterwards, you can use:<br> <code>git diff --staged</code> to check that you staged correct changes<br> <code>git reset -p</code> to unstage mistakenly added hunks<br> <code>git commit -v</code> to view your commit while you edit the commit message.</p> <p>Note this is far different than the <code>git format-patch</code> command, which purpose is to parse commit data into a <code>.patch</code> files.</p> <p>Reference for future: <a href="https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging" rel="noreferrer">https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging</a></p>
 

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