# git push --delete <url> <branch> fails if run outside a repository

2 messages from 2022-06-06 to 2022-06-06. Participants: Adam Dinwoodie, Junio C Hamano.
Thread: https://gitlist.dev/t/57957

## Adam Dinwoodie, 2022-06-06 08:05

Subject: git push --delete <url> <branch> fails if run outside a repository
Message-ID: <20220606080528.rfugporpazoujceq@lucy.dinwoodie.org>
URL: https://gitlist.dev/e/20220606080528.rfugporpazoujceq%40lucy.dinwoodie.org

```
When using `git push`, rather than specifying a remote by name, one can
also specify a remote by URL, and this includes when the only operations
being performed are to delete refs on the remote.  This doesn't require
any information about any local repository, but it fails unless the
command is run from within an existing local Git repo.

This seems like a bug to me: there's no reason this shouldn't work.
Clearly low priority, though, as this is a rare use case, and there's a
simple workaround: just `cd` into any existing Git repo, or create a
temporary empty repo to run the command from.

Simple test case attached; I've verified the behaviour the test script
demonstrates on Git v2.36.1 on Cygwin, and on Git v2.34.1 (strictly,
v2.34.1-1~bpo11) on Debian 11.

Cheers,

Adam

```

## Junio C Hamano, 2022-06-06 17:29

Subject: Re: git push --delete <url> <branch> fails if run outside a repository
Message-ID: <xmqqpmjl8zu9.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqpmjl8zu9.fsf%40gitster.g
In-Reply-To: <20220606080528.rfugporpazoujceq@lucy.dinwoodie.org>

```
Adam Dinwoodie <adam@dinwoodie.org> writes:

> When using `git push`, rather than specifying a remote by name, one can
> also specify a remote by URL, and this includes when the only operations
> being performed are to delete refs on the remote.  This doesn't require
> any information about any local repository, but it fails unless the
> command is run from within an existing local Git repo.
>
> This seems like a bug to me: there's no reason this shouldn't work.

Perhaps.

While I fully agree with you that there is no reason this shouldn't
work, I am not sure if there is a good reason to make it work,
either.  Any other push needs to have objects on _our_ side and
requiring you to be in a repository is a sure way to do so.  I am
not convinced that it is worth our engineering effort to add a
special case for this, but patches that are cleanly done without
making too much damage to the existing code in readability and
maintainability are probably welcome.

Thanks.

```
