From af9ded5b7007a4fa9844be7ac1c86f7a6ef2e56a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Fri, 29 Mar 2019 17:38:58 +0700 Subject: checkout: advice how to get out of detached HEAD mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Detached HEAD mode is considered dangerous and confusing for newcomers and we print a big block of warning how to move forward. But we should also suggest the user the way to get out of it if they get into detached HEAD by mistake. While at there, I also suggest how to turn the advice off. This is another thing I find annoying with advices and should be dealt with in a more generic way. But that may require some refactoring in advice.c first. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- advice.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'advice.c') diff --git a/advice.c b/advice.c index 567209aa79..b224825637 100644 --- a/advice.c +++ b/advice.c @@ -191,13 +191,22 @@ void NORETURN die_conclude_merge(void) void detach_advice(const char *new_name) { const char *fmt = - _("Note: checking out '%s'.\n\n" + _("Note: checking out '%s'.\n" + "\n" "You are in 'detached HEAD' state. You can look around, make experimental\n" "changes and commit them, and you can discard any commits you make in this\n" - "state without impacting any branches by performing another checkout.\n\n" + "state without impacting any branches by performing another checkout.\n" + "\n" "If you want to create a new branch to retain commits you create, you may\n" - "do so (now or later) by using -b with the checkout command again. Example:\n\n" - " git checkout -b \n\n"); + "do so (now or later) by using -b with the checkout command again. Example:\n" + "\n" + " git checkout -b \n" + "\n" + "Or undo this checkout with:\n" + "\n" + " git checkout -\n" + "\n" + "Turn off this advice by setting config variable advice.detachedHead to false\n\n"); fprintf(stderr, fmt, new_name); } -- cgit v1.2.3 From 328c6cb853d7237098569de9f94bc3d259846a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Fri, 29 Mar 2019 17:39:19 +0700 Subject: doc: promote "git switch" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new command "git switch" is added to avoid the confusion of one-command-do-all "git checkout" for new users. They are also helpful to avoid ambiguation context. For these reasons, promote it everywhere possible. This includes documentation, suggestions/advice from other commands... The "Checking out files" progress line in unpack-trees.c is also updated to "Updating files" to be neutral to both git-checkout and git-switch. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- advice.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'advice.c') diff --git a/advice.c b/advice.c index b224825637..24a7741083 100644 --- a/advice.c +++ b/advice.c @@ -191,20 +191,20 @@ void NORETURN die_conclude_merge(void) void detach_advice(const char *new_name) { const char *fmt = - _("Note: checking out '%s'.\n" + _("Note: switching to '%s'.\n" "\n" "You are in 'detached HEAD' state. You can look around, make experimental\n" "changes and commit them, and you can discard any commits you make in this\n" - "state without impacting any branches by performing another checkout.\n" + "state without impacting any branches by switching back to a branch.\n" "\n" "If you want to create a new branch to retain commits you create, you may\n" - "do so (now or later) by using -b with the checkout command again. Example:\n" + "do so (now or later) by using -c with the switch command. Example:\n" "\n" - " git checkout -b \n" + " git switch -c \n" "\n" - "Or undo this checkout with:\n" + "Or undo this operation with:\n" "\n" - " git checkout -\n" + " git switch -\n" "\n" "Turn off this advice by setting config variable advice.detachedHead to false\n\n"); -- cgit v1.2.3