Skip to content

Recommend Use of git restore When Working With Files - #2187

Open
vermiceli wants to merge 1 commit into
git:gh-pagesfrom
vermiceli:patch-1
Open

Recommend Use of git restore When Working With Files#2187
vermiceli wants to merge 1 commit into
git:gh-pagesfrom
vermiceli:patch-1

Conversation

@vermiceli

@vermiceli vermiceli commented Jul 24, 2026

Copy link
Copy Markdown

Replaces git reset commands that deal with restoring files from the worktree or index with git restore.

I believe this better aligns with the documentation, in particular Reset, restore and revert

git-restore[1] is about restoring files in the working tree from either the index or another commit. This command does not update your branch. The command can also be used to restore files in the index from another commit.

git-reset[1] is about updating your branch, moving the tip in order to add or remove commits from the branch. This operation changes the commit history.

Replaces `git reset` commands that deal with restoring files from the working tree or index with `git restore`.

I believe this better aligns with the documentation, in particular [Reset, restore and revert](https://git-scm.com/docs/git#_reset_restore_and_revert)

> git-restore[1] is about restoring files in the working tree from either the index or another commit. This command does not update your branch. The command can also be used to restore files in the index from another commit.
> git-reset[1] is about updating your branch, moving the tip in order to add or remove commits from the branch. This operation changes the commit history.
@vermiceli vermiceli changed the title Update git commands for unstaging changes Recommend Use of git restore When Working With Files Jul 24, 2026
@dscho
dscho requested a review from jvns July 28, 2026 12:54
@jvns

jvns commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

I think this would be a good use of the "OR", like with "Delete unstaged changes to one file:" where we show both how to use git checkout and git restore.

I'm also curious about your experience with git restore -- do you yourself find it easier to use than git reset?

My impression is that many Git users (including me!) aren't really familiar with git restore yet, and giving both the "old" and "new" way to do it would help folks understand the new syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants