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:

committed by
Junio C Hamano

parent
fc991b43df
commit
80f537f79c
26
wt-status.c
26
wt-status.c
@ -178,9 +178,15 @@ static void wt_longstatus_print_unmerged_header(struct wt_status *s)
|
||||
return;
|
||||
if (s->whence != FROM_COMMIT)
|
||||
;
|
||||
else if (!s->is_initial)
|
||||
status_printf_ln(s, c, _(" (use \"git reset %s <file>...\" to unstage)"), s->reference);
|
||||
else
|
||||
else if (!s->is_initial) {
|
||||
if (!strcmp(s->reference, "HEAD"))
|
||||
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)"));
|
||||
|
||||
if (!both_deleted) {
|
||||
@ -205,9 +211,15 @@ static void wt_longstatus_print_cached_header(struct wt_status *s)
|
||||
return;
|
||||
if (s->whence != FROM_COMMIT)
|
||||
; /* NEEDSWORK: use "git reset --unresolve"??? */
|
||||
else if (!s->is_initial)
|
||||
status_printf_ln(s, c, _(" (use \"git reset %s <file>...\" to unstage)"), s->reference);
|
||||
else
|
||||
else if (!s->is_initial) {
|
||||
if (!strcmp(s->reference, "HEAD"))
|
||||
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, "%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)"));
|
||||
else
|
||||
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)
|
||||
status_printf_ln(s, c, _(" (commit or discard the untracked or modified content in submodules)"));
|
||||
status_printf_ln(s, c, "%s", "");
|
||||
|
Reference in New Issue
Block a user