Skip to content

Commit 30cca90

Browse files
authored
cheat sheet: Suggest git-restore for discarding changes
In modern versions of Git, `git status` will suggest using `git restore` in these cases. Also, in all other instances, the cheat sheet already lists `git switch` or `git restore` alternatives to `git checkout`.
1 parent 96f89d8 commit 30cca90

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

content/cheat-sheet/_index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,14 @@ <h2 id="ways-to-refer-to-a-commit">Ways to refer to a commit</h2>
212212
<h2 id="discard-your-changes">Discard Your Changes</h2>
213213
<div class="item">
214214
<h3>Delete unstaged changes to one file:</h3>
215+
<code>git restore &lt;file&gt;</code>
216+
<span class="or">OR</span>
215217
<code>git checkout &lt;file&gt;</code>
216218
</div>
217219
<div class="item">
218220
<h3>Delete all staged and unstaged changes to one file:</h3>
221+
<code>git restore --staged --worktree &lt;file&gt;</code>
222+
<span class="or">OR</span>
219223
<code>git checkout HEAD &lt;file&gt;</code>
220224
</div>
221225
<div class="item">

0 commit comments

Comments
 (0)