diff --git a/t/t6439-merge-co-error-msgs.sh b/t/t6439-merge-co-error-msgs.sh index 643c9368e0e841..6ccc1e0416667a 100755 --- a/t/t6439-merge-co-error-msgs.sh +++ b/t/t6439-merge-co-error-msgs.sh @@ -76,7 +76,8 @@ cat >expect <<\EOF error: Your local changes to the following files would be overwritten by checkout: rep/one rep/two -Please commit your changes or stash them before you switch branches. +To move you local changes safely to the other branch, +Please try 'git stash' followed by 'git checkout ' followed by 'git stash pop' for safe merge. Aborting EOF @@ -98,7 +99,8 @@ cat >expect <<\EOF error: Your local changes to the following files would be overwritten by checkout: rep/one rep/two -Please commit your changes or stash them before you switch branches. +To move you local changes safely to the other branch, +Please try 'git stash' followed by 'git checkout ' followed by 'git stash pop' for safe merge. Aborting EOF diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index 3adab12091a5f0..1ba15918a51d81 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -211,7 +211,8 @@ test_expect_success 'submodule update should fail due to local changes' ' sed "s/^> //" >expect <<-\EOF && > error: Your local changes to the following files would be overwritten by checkout: > file - > Please commit your changes or stash them before you switch branches. + > To move you local changes safely to the other branch, + > Please try '\''git stash'\'' followed by '\''git checkout '\'' followed by '\''git stash pop'\'' for safe merge. > Aborting > fatal: Unable to checkout OID in submodule path '\''submodule'\'' EOF diff --git a/unpack-trees.c b/unpack-trees.c index 998a1e6dc70cae..e817477926f874 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -128,8 +128,11 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts, if (!strcmp(cmd, "checkout")) msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE) ? _("Your local changes to the following files would be overwritten by checkout:\n%%s" - "Please commit your changes or stash them before you switch branches.") - : _("Your local changes to the following files would be overwritten by checkout:\n%%s"); + "To move you local changes safely to the other branch,\n" + "Please try 'git stash' followed by 'git checkout ' followed by 'git stash pop' for safe merge." + ) + : _("Your local changes to the following files would be overwritten by checkout:\n%%s" + "Please commit your changes or stash them before you switch branches."); else if (!strcmp(cmd, "merge")) msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE) ? _("Your local changes to the following files would be overwritten by merge:\n%%s"