doc: promote "git restore"

The new command "git restore" (together with "git switch") are added
to avoid the confusion of one-command-do-all "git checkout" for new
users. They are also helpful to avoid ambiguous context.

For these reasons, promote it everywhere possible. This includes
documentation, suggestions/advice from other commands.

One nice thing about git-restore is the ability to restore
"everything", so it can be used in "git status" advice instead of both
"git checkout" and "git reset".  The three commands suggested by "git
status" are add, rm and restore.

"git checkout" is also removed from "git help" (i.e. it's no longer
considered a commonly used command)

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Nguyễn Thái Ngọc Duy 2019-04-25 16:45:58 +07:00 committed by Junio C Hamano
parent fc991b43df
commit 80f537f79c
16 changed files with 93 additions and 84 deletions

View File

@ -64,7 +64,7 @@ OPTIONS
directory) and $GIT_DIR/info/exclude, but do still use the ignore directory) and $GIT_DIR/info/exclude, but do still use the ignore
rules given with `-e` options. This allows removing all untracked rules given with `-e` options. This allows removing all untracked
files, including build products. This can be used (possibly in files, including build products. This can be used (possibly in
conjunction with 'git reset') to create a pristine conjunction with 'git restore' or 'git reset') to create a pristine
working directory to test a clean build. working directory to test a clean build.
-X:: -X::

View File

@ -359,7 +359,7 @@ When recording your own work, the contents of modified files in
your working tree are temporarily stored to a staging area your working tree are temporarily stored to a staging area
called the "index" with 'git add'. A file can be called the "index" with 'git add'. A file can be
reverted back, only in the index but not in the working tree, reverted back, only in the index but not in the working tree,
to that of the last commit with `git reset HEAD -- <file>`, to that of the last commit with `git restore --staged <file>`,
which effectively reverts 'git add' and prevents the changes to which effectively reverts 'git add' and prevents the changes to
this file from participating in the next commit. After building this file from participating in the next commit. After building
the state to be committed incrementally with these commands, the state to be committed incrementally with these commands,

View File

@ -422,7 +422,7 @@ One way to test if your MUA is set up correctly is:
$ git fetch <project> master:test-apply $ git fetch <project> master:test-apply
$ git switch test-apply $ git switch test-apply
$ git reset --hard $ git restore --source=HEAD --staged --worktree :/
$ git am a.patch $ git am a.patch
If it does not apply correctly, there can be various reasons. If it does not apply correctly, there can be various reasons.

View File

@ -29,9 +29,9 @@ This means that `git reset <paths>` is the opposite of `git add
`git restore [--source=<tree-ish>] --staged <paths>...`. `git restore [--source=<tree-ish>] --staged <paths>...`.
+ +
After running `git reset <paths>` to update the index entry, you can After running `git reset <paths>` to update the index entry, you can
use linkgit:git-checkout[1] to check the contents out of the index to use linkgit:git-restore[1] to check the contents out of the index to
the working tree. the working tree. Alternatively, using linkgit:git-restore[1]
Alternatively, using linkgit:git-checkout[1] and specifying a commit, you and specifying a commit with `--source`, you
can copy the contents of a path out of a commit to the index and to the can copy the contents of a path out of a commit to the index and to the
working tree in one go. working tree in one go.

View File

@ -26,8 +26,8 @@ effect of some earlier commits (often only a faulty one). If you want to
throw away all uncommitted changes in your working directory, you throw away all uncommitted changes in your working directory, you
should see linkgit:git-reset[1], particularly the `--hard` option. If should see linkgit:git-reset[1], particularly the `--hard` option. If
you want to extract specific files as they were in another commit, you you want to extract specific files as they were in another commit, you
should see linkgit:git-checkout[1], specifically the `git checkout should see linkgit:git-restore[1], specifically the `--source`
<commit> -- <filename>` syntax. Take care with these alternatives as option. Take care with these alternatives as
both will discard uncommitted changes in your working directory. both will discard uncommitted changes in your working directory.
See "Reset, restore and revert" in linkgit:git[1] for the differences See "Reset, restore and revert" in linkgit:git[1] for the differences

View File

@ -47,8 +47,8 @@ disambiguating `--` at appropriate places.
things: things:
+ +
-------------------------------- --------------------------------
$ git checkout -- *.c $ git restore *.c
$ git checkout -- \*.c $ git restore \*.c
-------------------------------- --------------------------------
+ +
The former lets your shell expand the fileglob, and you are asking The former lets your shell expand the fileglob, and you are asking

View File

@ -51,8 +51,7 @@ following commands.
* linkgit:git-commit[1] to advance the current branch. * linkgit:git-commit[1] to advance the current branch.
* linkgit:git-reset[1] and linkgit:git-checkout[1] (with * linkgit:git-restore[1] to undo changes.
pathname parameters) to undo changes.
* linkgit:git-merge[1] to merge between local branches. * linkgit:git-merge[1] to merge between local branches.
@ -82,7 +81,7 @@ Create a topic branch and develop.::
------------ ------------
$ git switch -c alsa-audio <1> $ git switch -c alsa-audio <1>
$ edit/compile/test $ edit/compile/test
$ git checkout -- curses/ux_audio_oss.c <2> $ git restore curses/ux_audio_oss.c <2>
$ git add curses/ux_audio_alsa.c <3> $ git add curses/ux_audio_alsa.c <3>
$ edit/compile/test $ edit/compile/test
$ git diff HEAD <4> $ git diff HEAD <4>

View File

@ -370,13 +370,13 @@ situation:
$ git status $ git status
On branch master On branch master
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
new file: closing.txt new file: closing.txt
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: file.txt modified: file.txt

View File

@ -110,7 +110,7 @@ $ git status
On branch master On branch master
Changes to be committed: Changes to be committed:
Your branch is up to date with 'origin/master'. Your branch is up to date with 'origin/master'.
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
modified: file1 modified: file1
modified: file2 modified: file2

View File

@ -1446,7 +1446,7 @@ mistake, you can return the entire working tree to the last committed
state with state with
------------------------------------------------- -------------------------------------------------
$ git reset --hard HEAD $ git restore --staged --worktree :/
------------------------------------------------- -------------------------------------------------
If you make a commit that you later wish you hadn't, there are two If you make a commit that you later wish you hadn't, there are two
@ -1523,12 +1523,10 @@ Checking out an old version of a file
In the process of undoing a previous bad change, you may find it In the process of undoing a previous bad change, you may find it
useful to check out an older version of a particular file using useful to check out an older version of a particular file using
linkgit:git-checkout[1]. We've used `git checkout` before to switch linkgit:git-restore[1]. The command
branches, but it has quite different behavior if it is given a path
name: the command
------------------------------------------------- -------------------------------------------------
$ git checkout HEAD^ path/to/file $ git restore --source=HEAD^ path/to/file
------------------------------------------------- -------------------------------------------------
replaces path/to/file by the contents it had in the commit HEAD^, and replaces path/to/file by the contents it had in the commit HEAD^, and
@ -3800,8 +3798,8 @@ use linkgit:git-tag[1] for both.
The Workflow The Workflow
------------ ------------
High-level operations such as linkgit:git-commit[1], High-level operations such as linkgit:git-commit[1] and
linkgit:git-checkout[1] and linkgit:git-reset[1] work by moving data linkgit:git-restore[1] work by moving data
between the working tree, the index, and the object database. Git between the working tree, the index, and the object database. Git
provides low-level operations which perform each of these steps provides low-level operations which perform each of these steps
individually. individually.

View File

@ -492,7 +492,7 @@ static enum {
static const char junk_leave_repo_msg[] = static const char junk_leave_repo_msg[] =
N_("Clone succeeded, but checkout failed.\n" N_("Clone succeeded, but checkout failed.\n"
"You can inspect what was checked out with 'git status'\n" "You can inspect what was checked out with 'git status'\n"
"and retry the checkout with 'git checkout -f HEAD'\n"); "and retry with 'git restore --source=HEAD :/'\n");
static void remove_junk(void) static void remove_junk(void)
{ {

View File

@ -1676,7 +1676,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
if (commit_index_files()) if (commit_index_files())
die(_("repository has been updated, but unable to write\n" die(_("repository has been updated, but unable to write\n"
"new_index file. Check that disk is not full and quota is\n" "new_index file. Check that disk is not full and quota is\n"
"not exceeded, and then \"git reset HEAD\" to recover.")); "not exceeded, and then \"git restore --staged :/\" to recover."));
if (git_env_bool(GIT_TEST_COMMIT_GRAPH, 0)) if (git_env_bool(GIT_TEST_COMMIT_GRAPH, 0))
write_commit_graph_reachable(get_object_directory(), 0, 0); write_commit_graph_reachable(get_object_directory(), 0, 0);

View File

@ -59,7 +59,7 @@ git-cat-file plumbinginterrogators
git-check-attr purehelpers git-check-attr purehelpers
git-check-ignore purehelpers git-check-ignore purehelpers
git-check-mailmap purehelpers git-check-mailmap purehelpers
git-checkout mainporcelain history git-checkout mainporcelain
git-checkout-index plumbingmanipulators git-checkout-index plumbingmanipulators
git-check-ref-format purehelpers git-check-ref-format purehelpers
git-cherry plumbinginterrogators complete git-cherry plumbinginterrogators complete

View File

@ -94,13 +94,13 @@ test_expect_success 'status --column' '
# (use "git pull" to merge the remote branch into yours) # (use "git pull" to merge the remote branch into yours)
# #
# Changes to be committed: # Changes to be committed:
# (use "git reset HEAD <file>..." to unstage) # (use "git restore --staged <file>..." to unstage)
# #
# new file: dir2/added # new file: dir2/added
# #
# Changes not staged for commit: # Changes not staged for commit:
# (use "git add <file>..." to update what will be committed) # (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory) # (use "git restore <file>..." to discard changes in working directory)
# #
# modified: dir1/modified # modified: dir1/modified
# #
@ -128,13 +128,13 @@ cat >expect <<\EOF
# (use "git pull" to merge the remote branch into yours) # (use "git pull" to merge the remote branch into yours)
# #
# Changes to be committed: # Changes to be committed:
# (use "git reset HEAD <file>..." to unstage) # (use "git restore --staged <file>..." to unstage)
# #
# new file: dir2/added # new file: dir2/added
# #
# Changes not staged for commit: # Changes not staged for commit:
# (use "git add <file>..." to update what will be committed) # (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory) # (use "git restore <file>..." to discard changes in working directory)
# #
# modified: dir1/modified # modified: dir1/modified
# #
@ -278,13 +278,13 @@ and have 1 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours) (use "git pull" to merge the remote branch into yours)
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
new file: dir2/added new file: dir2/added
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: dir1/modified modified: dir1/modified
@ -347,13 +347,13 @@ and have 1 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours) (use "git pull" to merge the remote branch into yours)
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
new file: dir2/added new file: dir2/added
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: dir1/modified modified: dir1/modified
@ -420,13 +420,13 @@ and have 1 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours) (use "git pull" to merge the remote branch into yours)
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
new file: dir2/added new file: dir2/added
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: dir1/modified modified: dir1/modified
@ -484,13 +484,13 @@ and have 1 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours) (use "git pull" to merge the remote branch into yours)
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
new file: dir2/added new file: dir2/added
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: dir1/modified modified: dir1/modified
@ -542,13 +542,13 @@ and have 1 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours) (use "git pull" to merge the remote branch into yours)
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
new file: dir2/added new file: dir2/added
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: dir1/modified modified: dir1/modified
@ -605,13 +605,13 @@ and have 1 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours) (use "git pull" to merge the remote branch into yours)
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
new file: ../dir2/added new file: ../dir2/added
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: modified modified: modified
@ -676,13 +676,13 @@ and have 1 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours) (use "git pull" to merge the remote branch into yours)
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
<GREEN>new file: dir2/added<RESET> <GREEN>new file: dir2/added<RESET>
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
<RED>modified: dir1/modified<RESET> <RED>modified: dir1/modified<RESET>
@ -802,13 +802,13 @@ and have 1 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours) (use "git pull" to merge the remote branch into yours)
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
new file: dir2/added new file: dir2/added
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: dir1/modified modified: dir1/modified
@ -852,7 +852,7 @@ and have 1 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours) (use "git pull" to merge the remote branch into yours)
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
modified: dir1/modified modified: dir1/modified
@ -896,14 +896,14 @@ and have 1 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours) (use "git pull" to merge the remote branch into yours)
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
new file: dir2/added new file: dir2/added
new file: sm new file: sm
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: dir1/modified modified: dir1/modified
@ -956,14 +956,14 @@ and have 1 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours) (use "git pull" to merge the remote branch into yours)
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
new file: dir2/added new file: dir2/added
new file: sm new file: sm
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: dir1/modified modified: dir1/modified
@ -1019,7 +1019,7 @@ and have 2 and 2 different commits each, respectively.
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: dir1/modified modified: dir1/modified
@ -1068,14 +1068,14 @@ and have 2 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours) (use "git pull" to merge the remote branch into yours)
Changes to be committed: Changes to be committed:
(use "git reset HEAD^1 <file>..." to unstage) (use "git restore --source=HEAD^1 --staged <file>..." to unstage)
new file: dir2/added new file: dir2/added
new file: sm new file: sm
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: dir1/modified modified: dir1/modified
@ -1123,13 +1123,13 @@ and have 2 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours) (use "git pull" to merge the remote branch into yours)
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
modified: sm modified: sm
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: dir1/modified modified: dir1/modified
@ -1235,13 +1235,13 @@ and have 2 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours) (use "git pull" to merge the remote branch into yours)
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
modified: sm modified: sm
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules) (commit or discard the untracked or modified content in submodules)
modified: dir1/modified modified: dir1/modified
@ -1295,13 +1295,13 @@ and have 2 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours) (use "git pull" to merge the remote branch into yours)
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
modified: sm modified: sm
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: dir1/modified modified: dir1/modified
modified: sm (new commits) modified: sm (new commits)
@ -1379,13 +1379,13 @@ cat > expect << EOF
; (use "git pull" to merge the remote branch into yours) ; (use "git pull" to merge the remote branch into yours)
; ;
; Changes to be committed: ; Changes to be committed:
; (use "git reset HEAD <file>..." to unstage) ; (use "git restore --staged <file>..." to unstage)
; ;
; modified: sm ; modified: sm
; ;
; Changes not staged for commit: ; Changes not staged for commit:
; (use "git add <file>..." to update what will be committed) ; (use "git add <file>..." to update what will be committed)
; (use "git checkout -- <file>..." to discard changes in working directory) ; (use "git restore <file>..." to discard changes in working directory)
; ;
; modified: dir1/modified ; modified: dir1/modified
; modified: sm (new commits) ; modified: sm (new commits)
@ -1431,7 +1431,7 @@ and have 2 and 2 different commits each, respectively.
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: dir1/modified modified: dir1/modified
@ -1458,13 +1458,13 @@ and have 2 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours) (use "git pull" to merge the remote branch into yours)
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
modified: sm modified: sm
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: dir1/modified modified: dir1/modified
@ -1581,13 +1581,13 @@ and have 2 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours) (use "git pull" to merge the remote branch into yours)
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
modified: sm modified: sm
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: dir1/modified modified: dir1/modified

View File

@ -85,7 +85,7 @@ You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
(use "git rebase --abort" to check out the original branch) (use "git rebase --abort" to check out the original branch)
Unmerged paths: Unmerged paths:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
(use "git add <file>..." to mark resolution) (use "git add <file>..." to mark resolution)
both modified: main.txt both modified: main.txt
@ -110,7 +110,7 @@ You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
(all conflicts fixed: run "git rebase --continue") (all conflicts fixed: run "git rebase --continue")
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
modified: main.txt modified: main.txt
@ -148,7 +148,7 @@ You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO
(use "git rebase --abort" to check out the original branch) (use "git rebase --abort" to check out the original branch)
Unmerged paths: Unmerged paths:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
(use "git add <file>..." to mark resolution) (use "git add <file>..." to mark resolution)
both modified: main.txt both modified: main.txt
@ -176,7 +176,7 @@ You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO
(all conflicts fixed: run "git rebase --continue") (all conflicts fixed: run "git rebase --continue")
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
modified: main.txt modified: main.txt
@ -246,7 +246,7 @@ You are currently splitting a commit while rebasing branch '\''split_commit'\''
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: main.txt modified: main.txt
@ -354,7 +354,7 @@ You are currently splitting a commit while rebasing branch '\''several_edits'\''
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: main.txt modified: main.txt
@ -453,7 +453,7 @@ You are currently splitting a commit while rebasing branch '\''several_edits'\''
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: main.txt modified: main.txt
@ -557,7 +557,7 @@ You are currently splitting a commit while rebasing branch '\''several_edits'\''
Changes not staged for commit: Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) (use "git restore <file>..." to discard changes in working directory)
modified: main.txt modified: main.txt
@ -816,7 +816,7 @@ You are currently reverting commit $TO_REVERT.
(use "git revert --abort" to cancel the revert operation) (use "git revert --abort" to cancel the revert operation)
Unmerged paths: Unmerged paths:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
(use "git add <file>..." to mark resolution) (use "git add <file>..." to mark resolution)
both modified: to-revert.txt both modified: to-revert.txt
@ -837,7 +837,7 @@ You are currently reverting commit $TO_REVERT.
(use "git revert --abort" to cancel the revert operation) (use "git revert --abort" to cancel the revert operation)
Changes to be committed: Changes to be committed:
(use "git reset HEAD <file>..." to unstage) (use "git restore --staged <file>..." to unstage)
modified: to-revert.txt modified: to-revert.txt

View File

@ -178,9 +178,15 @@ static void wt_longstatus_print_unmerged_header(struct wt_status *s)
return; return;
if (s->whence != FROM_COMMIT) if (s->whence != FROM_COMMIT)
; ;
else if (!s->is_initial) else if (!s->is_initial) {
status_printf_ln(s, c, _(" (use \"git reset %s <file>...\" to unstage)"), s->reference); if (!strcmp(s->reference, "HEAD"))
else status_printf_ln(s, c,
_(" (use \"git restore --staged <file>...\" to unstage)"));
else
status_printf_ln(s, c,
_(" (use \"git restore --source=%s --staged <file>...\" to unstage)"),
s->reference);
} else
status_printf_ln(s, c, _(" (use \"git rm --cached <file>...\" to unstage)")); status_printf_ln(s, c, _(" (use \"git rm --cached <file>...\" to unstage)"));
if (!both_deleted) { if (!both_deleted) {
@ -205,9 +211,15 @@ static void wt_longstatus_print_cached_header(struct wt_status *s)
return; return;
if (s->whence != FROM_COMMIT) if (s->whence != FROM_COMMIT)
; /* NEEDSWORK: use "git reset --unresolve"??? */ ; /* NEEDSWORK: use "git reset --unresolve"??? */
else if (!s->is_initial) else if (!s->is_initial) {
status_printf_ln(s, c, _(" (use \"git reset %s <file>...\" to unstage)"), s->reference); if (!strcmp(s->reference, "HEAD"))
else status_printf_ln(s, c
, _(" (use \"git restore --staged <file>...\" to unstage)"));
else
status_printf_ln(s, c,
_(" (use \"git restore --source=%s --staged <file>...\" to unstage)"),
s->reference);
} else
status_printf_ln(s, c, _(" (use \"git rm --cached <file>...\" to unstage)")); status_printf_ln(s, c, _(" (use \"git rm --cached <file>...\" to unstage)"));
status_printf_ln(s, c, "%s", ""); status_printf_ln(s, c, "%s", "");
} }
@ -225,7 +237,7 @@ static void wt_longstatus_print_dirty_header(struct wt_status *s,
status_printf_ln(s, c, _(" (use \"git add <file>...\" to update what will be committed)")); status_printf_ln(s, c, _(" (use \"git add <file>...\" to update what will be committed)"));
else else
status_printf_ln(s, c, _(" (use \"git add/rm <file>...\" to update what will be committed)")); status_printf_ln(s, c, _(" (use \"git add/rm <file>...\" to update what will be committed)"));
status_printf_ln(s, c, _(" (use \"git checkout -- <file>...\" to discard changes in working directory)")); status_printf_ln(s, c, _(" (use \"git restore <file>...\" to discard changes in working directory)"));
if (has_dirty_submodules) if (has_dirty_submodules)
status_printf_ln(s, c, _(" (commit or discard the untracked or modified content in submodules)")); status_printf_ln(s, c, _(" (commit or discard the untracked or modified content in submodules)"));
status_printf_ln(s, c, "%s", ""); status_printf_ln(s, c, "%s", "");