threads / patch / 17890

patch, 6 partsImprove error message for branching an existing branch

Subject: [PATCH 3/6] Improve error message for branching an existing branch

## tl;dr

One message between Feb 19, 2009 and Feb 19, 2009. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

John Tapsell· Feb 19, 2009, 07:36 UTC · lore
Signed-off-by: John Tapsell <johnflux@gmail.com>
---
 branch.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Show changes to branch.c +2 −1
diff --git a/branch.c b/branch.c
index 1f00e44..86ac293 100644
--- a/branch.c
+++ b/branch.c
@@ -120,7 +120,8 @@ void create_branch(const char *head,
 
 	if (resolve_ref(ref.buf, sha1, 1, NULL)) {
 		if (!force)
-			die("A branch named '%s' already exists.", name);
+			die("A branch named '%s' already exists.\n"
+			    "Maybe you wanted to change to this branch with: git checkout '%s'", name, name);
 		else if (!is_bare_repository() && !strcmp(head, name))
 			die("Cannot force update the current branch.");
 		forcing = 1;
-- 
1.6.2.rc1.3.g7d31b.dirty

← back to recent threads