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>

Nguyễn Thái Ngọc Duy committed Apr 25, 2019 at 16:45 UTC 80f537f79c16efeb7b92b3409ede434a230b5679
16 files changed +93 -84
Documentation/git-clean.txt
+1 -1
@@ -64,7 +64,7 @@ OPTIONS
64 directory) and $GIT_DIR/info/exclude, but do still use the ignore
65 rules given with `-e` options. This allows removing all untracked
66 files, including build products. This can be used (possibly in
67 - conjunction with 'git reset') to create a pristine
67 + conjunction with 'git restore' or 'git reset') to create a pristine
68 working directory to test a clean build.
69
70 -X::
Documentation/git-commit.txt
+1 -1
@@ -359,7 +359,7 @@ When recording your own work, the contents of modified files in
359 your working tree are temporarily stored to a staging area
360 called the "index" with 'git add'. A file can be
361 reverted back, only in the index but not in the working tree,
362 -to that of the last commit with `git reset HEAD -- <file>`,
362 +to that of the last commit with `git restore --staged <file>`,
363 which effectively reverts 'git add' and prevents the changes to
364 this file from participating in the next commit. After building
365 the state to be committed incrementally with these commands,
Documentation/git-format-patch.txt
+1 -1
@@ -422,7 +422,7 @@ One way to test if your MUA is set up correctly is:
422
423 $ git fetch <project> master:test-apply
424 $ git switch test-apply
425 - $ git reset --hard
425 + $ git restore --source=HEAD --staged --worktree :/
426 $ git am a.patch
427
428 If it does not apply correctly, there can be various reasons.
Documentation/git-reset.txt
+3 -3
@@ -29,9 +29,9 @@ This means that `git reset <paths>` is the opposite of `git add
29 `git restore [--source=<tree-ish>] --staged <paths>...`.
30 +
31 After running `git reset <paths>` to update the index entry, you can
32 -use linkgit:git-checkout[1] to check the contents out of the index to
33 -the working tree.
34 -Alternatively, using linkgit:git-checkout[1] and specifying a commit, you
32 +use linkgit:git-restore[1] to check the contents out of the index to
33 +the working tree. Alternatively, using linkgit:git-restore[1]
34 +and specifying a commit with `--source`, you
35 can copy the contents of a path out of a commit to the index and to the
36 working tree in one go.
37
Documentation/git-revert.txt
+2 -2
@@ -26,8 +26,8 @@ effect of some earlier commits (often only a faulty one). If you want to
26 throw away all uncommitted changes in your working directory, you
27 should see linkgit:git-reset[1], particularly the `--hard` option. If
28 you want to extract specific files as they were in another commit, you
29 -should see linkgit:git-checkout[1], specifically the `git checkout
30 -<commit> -- <filename>` syntax. Take care with these alternatives as
29 +should see linkgit:git-restore[1], specifically the `--source`
30 +option. Take care with these alternatives as
31 both will discard uncommitted changes in your working directory.
32
33 See "Reset, restore and revert" in linkgit:git[1] for the differences
Documentation/gitcli.txt
+2 -2
@@ -47,8 +47,8 @@ disambiguating `--` at appropriate places.
47 things:
48 +
49 --------------------------------
50 -$ git checkout -- *.c
51 -$ git checkout -- \*.c
50 +$ git restore *.c
51 +$ git restore \*.c
52 --------------------------------
53 +
54 The former lets your shell expand the fileglob, and you are asking
Documentation/giteveryday.txt
+2 -3
@@ -51,8 +51,7 @@ following commands.
51
52 * linkgit:git-commit[1] to advance the current branch.
53
54 - * linkgit:git-reset[1] and linkgit:git-checkout[1] (with
55 - pathname parameters) to undo changes.
54 + * linkgit:git-restore[1] to undo changes.
55
56 * linkgit:git-merge[1] to merge between local branches.
57
@@ -82,7 +81,7 @@ Create a topic branch and develop.::
81 ------------
82 $ git switch -c alsa-audio <1>
83 $ edit/compile/test
85 -$ git checkout -- curses/ux_audio_oss.c <2>
84 +$ git restore curses/ux_audio_oss.c <2>
85 $ git add curses/ux_audio_alsa.c <3>
86 $ edit/compile/test
87 $ git diff HEAD <4>
Documentation/gittutorial-2.txt
+2 -2
@@ -370,13 +370,13 @@ situation:
370 $ git status
371 On branch master
372 Changes to be committed:
373 - (use "git reset HEAD <file>..." to unstage)
373 + (use "git restore --staged <file>..." to unstage)
374
375 new file: closing.txt
376
377 Changes not staged for commit:
378 (use "git add <file>..." to update what will be committed)
379 - (use "git checkout -- <file>..." to discard changes in working directory)
379 + (use "git restore <file>..." to discard changes in working directory)
380
381 modified: file.txt
382
Documentation/gittutorial.txt
+1 -1
@@ -110,7 +110,7 @@ $ git status
110 On branch master
111 Changes to be committed:
112 Your branch is up to date with 'origin/master'.
113 - (use "git reset HEAD <file>..." to unstage)
113 + (use "git restore --staged <file>..." to unstage)
114
115 modified: file1
116 modified: file2
Documentation/user-manual.txt
+5 -7
@@ -1446,7 +1446,7 @@ mistake, you can return the entire working tree to the last committed
1446 state with
1447
1448 -------------------------------------------------
1449 -$ git reset --hard HEAD
1449 +$ git restore --staged --worktree :/
1450 -------------------------------------------------
1451
1452 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
1523
1524 In the process of undoing a previous bad change, you may find it
1525 useful to check out an older version of a particular file using
1526 -linkgit:git-checkout[1]. We've used `git checkout` before to switch
1527 -branches, but it has quite different behavior if it is given a path
1528 -name: the command
1526 +linkgit:git-restore[1]. The command
1527
1528 -------------------------------------------------
1531 -$ git checkout HEAD^ path/to/file
1529 +$ git restore --source=HEAD^ path/to/file
1530 -------------------------------------------------
1531
1532 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.
3798 The Workflow
3799 ------------
3800
3803 -High-level operations such as linkgit:git-commit[1],
3804 -linkgit:git-checkout[1] and linkgit:git-reset[1] work by moving data
3801 +High-level operations such as linkgit:git-commit[1] and
3802 +linkgit:git-restore[1] work by moving data
3803 between the working tree, the index, and the object database. Git
3804 provides low-level operations which perform each of these steps
3805 individually.
builtin/clone.c
+1 -1
@@ -492,7 +492,7 @@ static enum {
492 static const char junk_leave_repo_msg[] =
493 N_("Clone succeeded, but checkout failed.\n"
494 "You can inspect what was checked out with 'git status'\n"
495 - "and retry the checkout with 'git checkout -f HEAD'\n");
495 + "and retry with 'git restore --source=HEAD :/'\n");
496
497 static void remove_junk(void)
498 {
builtin/commit.c
+1 -1
@@ -1676,7 +1676,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1676 if (commit_index_files())
1677 die(_("repository has been updated, but unable to write\n"
1678 "new_index file. Check that disk is not full and quota is\n"
1679 - "not exceeded, and then \"git reset HEAD\" to recover."));
1679 + "not exceeded, and then \"git restore --staged :/\" to recover."));
1680
1681 if (git_env_bool(GIT_TEST_COMMIT_GRAPH, 0))
1682 write_commit_graph_reachable(get_object_directory(), 0, 0);
command-list.txt
+1 -1
@@ -59,7 +59,7 @@ git-cat-file plumbinginterrogators
59 git-check-attr purehelpers
60 git-check-ignore purehelpers
61 git-check-mailmap purehelpers
62 -git-checkout mainporcelain history
62 +git-checkout mainporcelain
63 git-checkout-index plumbingmanipulators
64 git-check-ref-format purehelpers
65 git-cherry plumbinginterrogators complete
t/t7508-status.sh
+41 -41
@@ -94,13 +94,13 @@ test_expect_success 'status --column' '
94 # (use "git pull" to merge the remote branch into yours)
95 #
96 # Changes to be committed:
97 -# (use "git reset HEAD <file>..." to unstage)
97 +# (use "git restore --staged <file>..." to unstage)
98 #
99 # new file: dir2/added
100 #
101 # Changes not staged for commit:
102 # (use "git add <file>..." to update what will be committed)
103 -# (use "git checkout -- <file>..." to discard changes in working directory)
103 +# (use "git restore <file>..." to discard changes in working directory)
104 #
105 # modified: dir1/modified
106 #
@@ -128,13 +128,13 @@ cat >expect <<\EOF
128 # (use "git pull" to merge the remote branch into yours)
129 #
130 # Changes to be committed:
131 -# (use "git reset HEAD <file>..." to unstage)
131 +# (use "git restore --staged <file>..." to unstage)
132 #
133 # new file: dir2/added
134 #
135 # Changes not staged for commit:
136 # (use "git add <file>..." to update what will be committed)
137 -# (use "git checkout -- <file>..." to discard changes in working directory)
137 +# (use "git restore <file>..." to discard changes in working directory)
138 #
139 # modified: dir1/modified
140 #
@@ -278,13 +278,13 @@ and have 1 and 2 different commits each, respectively.
278 (use "git pull" to merge the remote branch into yours)
279
280 Changes to be committed:
281 - (use "git reset HEAD <file>..." to unstage)
281 + (use "git restore --staged <file>..." to unstage)
282
283 new file: dir2/added
284
285 Changes not staged for commit:
286 (use "git add <file>..." to update what will be committed)
287 - (use "git checkout -- <file>..." to discard changes in working directory)
287 + (use "git restore <file>..." to discard changes in working directory)
288
289 modified: dir1/modified
290
@@ -347,13 +347,13 @@ and have 1 and 2 different commits each, respectively.
347 (use "git pull" to merge the remote branch into yours)
348
349 Changes to be committed:
350 - (use "git reset HEAD <file>..." to unstage)
350 + (use "git restore --staged <file>..." to unstage)
351
352 new file: dir2/added
353
354 Changes not staged for commit:
355 (use "git add <file>..." to update what will be committed)
356 - (use "git checkout -- <file>..." to discard changes in working directory)
356 + (use "git restore <file>..." to discard changes in working directory)
357
358 modified: dir1/modified
359
@@ -420,13 +420,13 @@ and have 1 and 2 different commits each, respectively.
420 (use "git pull" to merge the remote branch into yours)
421
422 Changes to be committed:
423 - (use "git reset HEAD <file>..." to unstage)
423 + (use "git restore --staged <file>..." to unstage)
424
425 new file: dir2/added
426
427 Changes not staged for commit:
428 (use "git add <file>..." to update what will be committed)
429 - (use "git checkout -- <file>..." to discard changes in working directory)
429 + (use "git restore <file>..." to discard changes in working directory)
430
431 modified: dir1/modified
432
@@ -484,13 +484,13 @@ and have 1 and 2 different commits each, respectively.
484 (use "git pull" to merge the remote branch into yours)
485
486 Changes to be committed:
487 - (use "git reset HEAD <file>..." to unstage)
487 + (use "git restore --staged <file>..." to unstage)
488
489 new file: dir2/added
490
491 Changes not staged for commit:
492 (use "git add <file>..." to update what will be committed)
493 - (use "git checkout -- <file>..." to discard changes in working directory)
493 + (use "git restore <file>..." to discard changes in working directory)
494
495 modified: dir1/modified
496
@@ -542,13 +542,13 @@ and have 1 and 2 different commits each, respectively.
542 (use "git pull" to merge the remote branch into yours)
543
544 Changes to be committed:
545 - (use "git reset HEAD <file>..." to unstage)
545 + (use "git restore --staged <file>..." to unstage)
546
547 new file: dir2/added
548
549 Changes not staged for commit:
550 (use "git add <file>..." to update what will be committed)
551 - (use "git checkout -- <file>..." to discard changes in working directory)
551 + (use "git restore <file>..." to discard changes in working directory)
552
553 modified: dir1/modified
554
@@ -605,13 +605,13 @@ and have 1 and 2 different commits each, respectively.
605 (use "git pull" to merge the remote branch into yours)
606
607 Changes to be committed:
608 - (use "git reset HEAD <file>..." to unstage)
608 + (use "git restore --staged <file>..." to unstage)
609
610 new file: ../dir2/added
611
612 Changes not staged for commit:
613 (use "git add <file>..." to update what will be committed)
614 - (use "git checkout -- <file>..." to discard changes in working directory)
614 + (use "git restore <file>..." to discard changes in working directory)
615
616 modified: modified
617
@@ -676,13 +676,13 @@ and have 1 and 2 different commits each, respectively.
676 (use "git pull" to merge the remote branch into yours)
677
678 Changes to be committed:
679 - (use "git reset HEAD <file>..." to unstage)
679 + (use "git restore --staged <file>..." to unstage)
680
681 <GREEN>new file: dir2/added<RESET>
682
683 Changes not staged for commit:
684 (use "git add <file>..." to update what will be committed)
685 - (use "git checkout -- <file>..." to discard changes in working directory)
685 + (use "git restore <file>..." to discard changes in working directory)
686
687 <RED>modified: dir1/modified<RESET>
688
@@ -802,13 +802,13 @@ and have 1 and 2 different commits each, respectively.
802 (use "git pull" to merge the remote branch into yours)
803
804 Changes to be committed:
805 - (use "git reset HEAD <file>..." to unstage)
805 + (use "git restore --staged <file>..." to unstage)
806
807 new file: dir2/added
808
809 Changes not staged for commit:
810 (use "git add <file>..." to update what will be committed)
811 - (use "git checkout -- <file>..." to discard changes in working directory)
811 + (use "git restore <file>..." to discard changes in working directory)
812
813 modified: dir1/modified
814
@@ -852,7 +852,7 @@ and have 1 and 2 different commits each, respectively.
852 (use "git pull" to merge the remote branch into yours)
853
854 Changes to be committed:
855 - (use "git reset HEAD <file>..." to unstage)
855 + (use "git restore --staged <file>..." to unstage)
856
857 modified: dir1/modified
858
@@ -896,14 +896,14 @@ and have 1 and 2 different commits each, respectively.
896 (use "git pull" to merge the remote branch into yours)
897
898 Changes to be committed:
899 - (use "git reset HEAD <file>..." to unstage)
899 + (use "git restore --staged <file>..." to unstage)
900
901 new file: dir2/added
902 new file: sm
903
904 Changes not staged for commit:
905 (use "git add <file>..." to update what will be committed)
906 - (use "git checkout -- <file>..." to discard changes in working directory)
906 + (use "git restore <file>..." to discard changes in working directory)
907
908 modified: dir1/modified
909
@@ -956,14 +956,14 @@ and have 1 and 2 different commits each, respectively.
956 (use "git pull" to merge the remote branch into yours)
957
958 Changes to be committed:
959 - (use "git reset HEAD <file>..." to unstage)
959 + (use "git restore --staged <file>..." to unstage)
960
961 new file: dir2/added
962 new file: sm
963
964 Changes not staged for commit:
965 (use "git add <file>..." to update what will be committed)
966 - (use "git checkout -- <file>..." to discard changes in working directory)
966 + (use "git restore <file>..." to discard changes in working directory)
967
968 modified: dir1/modified
969
@@ -1019,7 +1019,7 @@ and have 2 and 2 different commits each, respectively.
1019
1020 Changes not staged for commit:
1021 (use "git add <file>..." to update what will be committed)
1022 - (use "git checkout -- <file>..." to discard changes in working directory)
1022 + (use "git restore <file>..." to discard changes in working directory)
1023
1024 modified: dir1/modified
1025
@@ -1068,14 +1068,14 @@ and have 2 and 2 different commits each, respectively.
1068 (use "git pull" to merge the remote branch into yours)
1069
1070 Changes to be committed:
1071 - (use "git reset HEAD^1 <file>..." to unstage)
1071 + (use "git restore --source=HEAD^1 --staged <file>..." to unstage)
1072
1073 new file: dir2/added
1074 new file: sm
1075
1076 Changes not staged for commit:
1077 (use "git add <file>..." to update what will be committed)
1078 - (use "git checkout -- <file>..." to discard changes in working directory)
1078 + (use "git restore <file>..." to discard changes in working directory)
1079
1080 modified: dir1/modified
1081
@@ -1123,13 +1123,13 @@ and have 2 and 2 different commits each, respectively.
1123 (use "git pull" to merge the remote branch into yours)
1124
1125 Changes to be committed:
1126 - (use "git reset HEAD <file>..." to unstage)
1126 + (use "git restore --staged <file>..." to unstage)
1127
1128 modified: sm
1129
1130 Changes not staged for commit:
1131 (use "git add <file>..." to update what will be committed)
1132 - (use "git checkout -- <file>..." to discard changes in working directory)
1132 + (use "git restore <file>..." to discard changes in working directory)
1133
1134 modified: dir1/modified
1135
@@ -1235,13 +1235,13 @@ and have 2 and 2 different commits each, respectively.
1235 (use "git pull" to merge the remote branch into yours)
1236
1237 Changes to be committed:
1238 - (use "git reset HEAD <file>..." to unstage)
1238 + (use "git restore --staged <file>..." to unstage)
1239
1240 modified: sm
1241
1242 Changes not staged for commit:
1243 (use "git add <file>..." to update what will be committed)
1244 - (use "git checkout -- <file>..." to discard changes in working directory)
1244 + (use "git restore <file>..." to discard changes in working directory)
1245 (commit or discard the untracked or modified content in submodules)
1246
1247 modified: dir1/modified
@@ -1295,13 +1295,13 @@ and have 2 and 2 different commits each, respectively.
1295 (use "git pull" to merge the remote branch into yours)
1296
1297 Changes to be committed:
1298 - (use "git reset HEAD <file>..." to unstage)
1298 + (use "git restore --staged <file>..." to unstage)
1299
1300 modified: sm
1301
1302 Changes not staged for commit:
1303 (use "git add <file>..." to update what will be committed)
1304 - (use "git checkout -- <file>..." to discard changes in working directory)
1304 + (use "git restore <file>..." to discard changes in working directory)
1305
1306 modified: dir1/modified
1307 modified: sm (new commits)
@@ -1379,13 +1379,13 @@ cat > expect << EOF
1379 ; (use "git pull" to merge the remote branch into yours)
1380 ;
1381 ; Changes to be committed:
1382 -; (use "git reset HEAD <file>..." to unstage)
1382 +; (use "git restore --staged <file>..." to unstage)
1383 ;
1384 ; modified: sm
1385 ;
1386 ; Changes not staged for commit:
1387 ; (use "git add <file>..." to update what will be committed)
1388 -; (use "git checkout -- <file>..." to discard changes in working directory)
1388 +; (use "git restore <file>..." to discard changes in working directory)
1389 ;
1390 ; modified: dir1/modified
1391 ; modified: sm (new commits)
@@ -1431,7 +1431,7 @@ and have 2 and 2 different commits each, respectively.
1431
1432 Changes not staged for commit:
1433 (use "git add <file>..." to update what will be committed)
1434 - (use "git checkout -- <file>..." to discard changes in working directory)
1434 + (use "git restore <file>..." to discard changes in working directory)
1435
1436 modified: dir1/modified
1437
@@ -1458,13 +1458,13 @@ and have 2 and 2 different commits each, respectively.
1458 (use "git pull" to merge the remote branch into yours)
1459
1460 Changes to be committed:
1461 - (use "git reset HEAD <file>..." to unstage)
1461 + (use "git restore --staged <file>..." to unstage)
1462
1463 modified: sm
1464
1465 Changes not staged for commit:
1466 (use "git add <file>..." to update what will be committed)
1467 - (use "git checkout -- <file>..." to discard changes in working directory)
1467 + (use "git restore <file>..." to discard changes in working directory)
1468
1469 modified: dir1/modified
1470
@@ -1581,13 +1581,13 @@ and have 2 and 2 different commits each, respectively.
1581 (use "git pull" to merge the remote branch into yours)
1582
1583 Changes to be committed:
1584 - (use "git reset HEAD <file>..." to unstage)
1584 + (use "git restore --staged <file>..." to unstage)
1585
1586 modified: sm
1587
1588 Changes not staged for commit:
1589 (use "git add <file>..." to update what will be committed)
1590 - (use "git checkout -- <file>..." to discard changes in working directory)
1590 + (use "git restore <file>..." to discard changes in working directory)
1591
1592 modified: dir1/modified
1593
t/t7512-status-help.sh
+10 -10
@@ -85,7 +85,7 @@ You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
85 (use "git rebase --abort" to check out the original branch)
86
87 Unmerged paths:
88 - (use "git reset HEAD <file>..." to unstage)
88 + (use "git restore --staged <file>..." to unstage)
89 (use "git add <file>..." to mark resolution)
90
91 both modified: main.txt
@@ -110,7 +110,7 @@ You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
110 (all conflicts fixed: run "git rebase --continue")
111
112 Changes to be committed:
113 - (use "git reset HEAD <file>..." to unstage)
113 + (use "git restore --staged <file>..." to unstage)
114
115 modified: main.txt
116
@@ -148,7 +148,7 @@ You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO
148 (use "git rebase --abort" to check out the original branch)
149
150 Unmerged paths:
151 - (use "git reset HEAD <file>..." to unstage)
151 + (use "git restore --staged <file>..." to unstage)
152 (use "git add <file>..." to mark resolution)
153
154 both modified: main.txt
@@ -176,7 +176,7 @@ You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO
176 (all conflicts fixed: run "git rebase --continue")
177
178 Changes to be committed:
179 - (use "git reset HEAD <file>..." to unstage)
179 + (use "git restore --staged <file>..." to unstage)
180
181 modified: main.txt
182
@@ -246,7 +246,7 @@ You are currently splitting a commit while rebasing branch '\''split_commit'\''
246
247 Changes not staged for commit:
248 (use "git add <file>..." to update what will be committed)
249 - (use "git checkout -- <file>..." to discard changes in working directory)
249 + (use "git restore <file>..." to discard changes in working directory)
250
251 modified: main.txt
252
@@ -354,7 +354,7 @@ You are currently splitting a commit while rebasing branch '\''several_edits'\''
354
355 Changes not staged for commit:
356 (use "git add <file>..." to update what will be committed)
357 - (use "git checkout -- <file>..." to discard changes in working directory)
357 + (use "git restore <file>..." to discard changes in working directory)
358
359 modified: main.txt
360
@@ -453,7 +453,7 @@ You are currently splitting a commit while rebasing branch '\''several_edits'\''
453
454 Changes not staged for commit:
455 (use "git add <file>..." to update what will be committed)
456 - (use "git checkout -- <file>..." to discard changes in working directory)
456 + (use "git restore <file>..." to discard changes in working directory)
457
458 modified: main.txt
459
@@ -557,7 +557,7 @@ You are currently splitting a commit while rebasing branch '\''several_edits'\''
557
558 Changes not staged for commit:
559 (use "git add <file>..." to update what will be committed)
560 - (use "git checkout -- <file>..." to discard changes in working directory)
560 + (use "git restore <file>..." to discard changes in working directory)
561
562 modified: main.txt
563
@@ -816,7 +816,7 @@ You are currently reverting commit $TO_REVERT.
816 (use "git revert --abort" to cancel the revert operation)
817
818 Unmerged paths:
819 - (use "git reset HEAD <file>..." to unstage)
819 + (use "git restore --staged <file>..." to unstage)
820 (use "git add <file>..." to mark resolution)
821
822 both modified: to-revert.txt
@@ -837,7 +837,7 @@ You are currently reverting commit $TO_REVERT.
837 (use "git revert --abort" to cancel the revert operation)
838
839 Changes to be committed:
840 - (use "git reset HEAD <file>..." to unstage)
840 + (use "git restore --staged <file>..." to unstage)
841
842 modified: to-revert.txt
843
wt-status.c
+19 -7
@@ -178,9 +178,15 @@ static void wt_longstatus_print_unmerged_header(struct wt_status *s)
178 return;
179 if (s->whence != FROM_COMMIT)
180 ;
181 - else if (!s->is_initial)
182 - status_printf_ln(s, c, _(" (use \"git reset %s <file>...\" to unstage)"), s->reference);
183 - else
181 + else if (!s->is_initial) {
182 + if (!strcmp(s->reference, "HEAD"))
183 + status_printf_ln(s, c,
184 + _(" (use \"git restore --staged <file>...\" to unstage)"));
185 + else
186 + status_printf_ln(s, c,
187 + _(" (use \"git restore --source=%s --staged <file>...\" to unstage)"),
188 + s->reference);
189 + } else
190 status_printf_ln(s, c, _(" (use \"git rm --cached <file>...\" to unstage)"));
191
192 if (!both_deleted) {
@@ -205,9 +211,15 @@ static void wt_longstatus_print_cached_header(struct wt_status *s)
211 return;
212 if (s->whence != FROM_COMMIT)
213 ; /* NEEDSWORK: use "git reset --unresolve"??? */
208 - else if (!s->is_initial)
209 - status_printf_ln(s, c, _(" (use \"git reset %s <file>...\" to unstage)"), s->reference);
210 - else
214 + else if (!s->is_initial) {
215 + if (!strcmp(s->reference, "HEAD"))
216 + status_printf_ln(s, c
217 + , _(" (use \"git restore --staged <file>...\" to unstage)"));
218 + else
219 + status_printf_ln(s, c,
220 + _(" (use \"git restore --source=%s --staged <file>...\" to unstage)"),
221 + s->reference);
222 + } else
223 status_printf_ln(s, c, _(" (use \"git rm --cached <file>...\" to unstage)"));
224 status_printf_ln(s, c, "%s", "");
225 }
@@ -225,7 +237,7 @@ static void wt_longstatus_print_dirty_header(struct wt_status *s,
237 status_printf_ln(s, c, _(" (use \"git add <file>...\" to update what will be committed)"));
238 else
239 status_printf_ln(s, c, _(" (use \"git add/rm <file>...\" to update what will be committed)"));
228 - status_printf_ln(s, c, _(" (use \"git checkout -- <file>...\" to discard changes in working directory)"));
240 + status_printf_ln(s, c, _(" (use \"git restore <file>...\" to discard changes in working directory)"));
241 if (has_dirty_submodules)
242 status_printf_ln(s, c, _(" (commit or discard the untracked or modified content in submodules)"));
243 status_printf_ln(s, c, "%s", "");