<p><a href="/daily/2024/10/24/git-stash-is-underrated">In yesterday's email</a> where I wrote about <code>git stash</code>, I mentioned the <code>-p</code> or <code>--patch</code> options.</p>
<p>When stashing changes, this allows you to interactively select which changes you want to stash and what you don't.</p>
<p>This is supported by other Git commands, including <code>git add</code>.</p>
<p>I always use <code>git add -p</code> when adding changes as it gives me the chance to review them before committing them.</p>
<p>If I left any stray comments, debug code, trailing spaces or anything I don't want to commit, I can remove them.</p>
<p>If I was working on multiple changes (which I avoid), I can select the appropriate changes and create commits related to each change to keep the history clean and useful.</p>
<p>I also use <code>git diff</code> and <code>git diff --staged</code> to review changes as well as <code>git show</code> to review commits.</p>
<p>By doing this, I know my commits will be in the best state for others to review now or for me to review if I need to in the future.</p>
<p><a href="/daily/2024/10/24/git-stash-is-underrated">In yesterday's email</a> where I wrote about <code>git stash</code>, I mentioned the <code>-p</code> or <code>--patch</code> options.</p>
<p>When stashing changes, this allows you to interactively select which changes you want to stash and what you don't.</p>
<p>This is supported by other Git commands, including <code>git add</code>.</p>
<p>I always use <code>git add -p</code> when adding changes as it gives me the chance to review them before committing them.</p>
<p>If I left any stray comments, debug code, trailing spaces or anything I don't want to commit, I can remove them.</p>
<p>If I was working on multiple changes (which I avoid), I can select the appropriate changes and create commits related to each change to keep the history clean and useful.</p>
<p>I also use <code>git diff</code> and <code>git diff --staged</code> to review changes as well as <code>git show</code> to review commits.</p>
<p>By doing this, I know my commits will be in the best state for others to review now or for me to review if I need to in the future.</p>