{"thread":{"id":"44387","subject":"\"git push\" says \"src refspec XYZ matches more than one\" even without explicit XYZ argument.","startedAt":"2016-10-28T03:00:47Z","lastAt":"2016-10-28T19:13:27Z","messageCount":2,"participants":["Kannan Goundan","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"305038","messageId":"CAM7aVoUOxx6Fa+yG2JzQhoX-mE4Lgp9ejvwncx5bdL+1tuQQFg@mail.gmail.com","threadId":"44387","inReplyTo":null,"subject":"\"git push\" says \"src refspec XYZ matches more than one\" even without explicit XYZ argument.","fromName":"Kannan Goundan","fromEmail":"kannan@cakoose.com","sentAt":"2016-10-28T03:00:40Z","receivedAt":"2016-10-28T03:00:47Z","isPatch":false,"sender":{"key":"kannan@cakoose.com","avatar":null},"body":"1. My repo has a branch named 'v1' that is tracking 'origin/v1'.\n2. My repo has a tag named 'v1'.\n3. I have \"push.default\" set to \"upstream\".\n\nI made a commit on branch 'v1' and tried doing a push:\n\n    # git push\n    error: src refspec v1 matches more than one.\n    error: failed to push some refs to 'git@github.com:whatever/ns1-go.git'\n\nIf I rename the branch to 'v1-dev', then the push goes through.\n\nI understand why the command \"git push origin/v1 v1\" is ambiguous.\nBut if I do a plain \"git push\", I thought Git would know to push my\ncurrent branch.\n\n[Git version 2.10.1 from Homebrew on Mac OS 10.11.6.]\n"},{"id":"305118","messageId":"xmqq1sz01e41.fsf@gitster.mtv.corp.google.com","threadId":"44387","inReplyTo":"CAM7aVoUOxx6Fa+yG2JzQhoX-mE4Lgp9ejvwncx5bdL+1tuQQFg@mail.gmail.com","subject":"Re: \"git push\" says \"src refspec XYZ matches more than one\" even without explicit XYZ argument.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-10-28T19:13:18Z","receivedAt":"2016-10-28T19:13:27Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kannan Goundan <kannan@cakoose.com> writes:\n\n> 1. My repo has a branch named 'v1' that is tracking 'origin/v1'.\n> 2. My repo has a tag named 'v1'.\n> 3. I have \"push.default\" set to \"upstream\".\n>\n> I made a commit on branch 'v1' and tried doing a push:\n>\n>     # git push\n>     error: src refspec v1 matches more than one.\n>     error: failed to push some refs to 'git@github.com:whatever/ns1-go.git'\n>\n> If I rename the branch to 'v1-dev', then the push goes through.\n>\n> I understand why the command \"git push origin/v1 v1\" is ambiguous.\n> But if I do a plain \"git push\", I thought Git would know to push my\n> current branch.\n>\n> [Git version 2.10.1 from Homebrew on Mac OS 10.11.6.]\n\nThanks.  \n\nYou are right that the refspec Git internally create for this case\nshould not be v1:refs/heads/v1, which would notice that the source\nside (e.g. \"v1\") is ambiguous.  Instead we should spell that out.\n\nPerhaps something like this would fix it for you?\n\n builtin/push.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/push.c b/builtin/push.c\nindex 3bb9d6b7e6..02fd235742 100644\n--- a/builtin/push.c\n+++ b/builtin/push.c\n@@ -194,7 +194,7 @@ static void setup_push_upstream(struct remote *remote, struct branch *branch,\n \t\t\tdie_push_simple(branch, remote);\n \t}\n \n-\tstrbuf_addf(&refspec, \"%s:%s\", branch->name, branch->merge[0]->src);\n+\tstrbuf_addf(&refspec, \"%s:%s\", branch->refname, branch->merge[0]->src);\n \tadd_refspec(refspec.buf);\n }\n \n"}]}