{"thread":{"id":"57957","subject":"git push --delete <url> <branch> fails if run outside a repository","startedAt":"2022-06-06T08:05:38Z","lastAt":"2022-06-06T17:29:57Z","messageCount":2,"participants":["Adam Dinwoodie","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"456706","messageId":"20220606080528.rfugporpazoujceq@lucy.dinwoodie.org","threadId":"57957","inReplyTo":null,"subject":"git push --delete <url> <branch> fails if run outside a repository","fromName":"Adam Dinwoodie","fromEmail":"adam@dinwoodie.org","sentAt":"2022-06-06T08:05:28Z","receivedAt":"2022-06-06T08:05:38Z","isPatch":false,"sender":{"key":"adam@dinwoodie.org","avatar":"https://avatars.githubusercontent.com/u/1397507?v=4"},"body":"When using `git push`, rather than specifying a remote by name, one can\nalso specify a remote by URL, and this includes when the only operations\nbeing performed are to delete refs on the remote.  This doesn't require\nany information about any local repository, but it fails unless the\ncommand is run from within an existing local Git repo.\n\nThis seems like a bug to me: there's no reason this shouldn't work.\nClearly low priority, though, as this is a rare use case, and there's a\nsimple workaround: just `cd` into any existing Git repo, or create a\ntemporary empty repo to run the command from.\n\nSimple test case attached; I've verified the behaviour the test script\ndemonstrates on Git v2.36.1 on Cygwin, and on Git v2.34.1 (strictly,\nv2.34.1-1~bpo11) on Debian 11.\n\nCheers,\n\nAdam\n"},{"id":"456728","messageId":"xmqqpmjl8zu9.fsf@gitster.g","threadId":"57957","inReplyTo":"20220606080528.rfugporpazoujceq@lucy.dinwoodie.org","subject":"Re: git push --delete <url> <branch> fails if run outside a repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-06-06T17:29:50Z","receivedAt":"2022-06-06T17:29:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Adam Dinwoodie <adam@dinwoodie.org> writes:\n\n> When using `git push`, rather than specifying a remote by name, one can\n> also specify a remote by URL, and this includes when the only operations\n> being performed are to delete refs on the remote.  This doesn't require\n> any information about any local repository, but it fails unless the\n> command is run from within an existing local Git repo.\n>\n> This seems like a bug to me: there's no reason this shouldn't work.\n\nPerhaps.\n\nWhile I fully agree with you that there is no reason this shouldn't\nwork, I am not sure if there is a good reason to make it work,\neither.  Any other push needs to have objects on _our_ side and\nrequiring you to be in a repository is a sure way to do so.  I am\nnot convinced that it is worth our engineering effort to add a\nspecial case for this, but patches that are cleanly done without\nmaking too much damage to the existing code in readability and\nmaintainability are probably welcome.\n\nThanks.\n"}]}