git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Convenient shortcut to push delete current branch?

From
Jacob Keller <jacob.keller@gmail.com>
Date
Oct 1, 2015, 18:22 UTC
Message-ID
<CA+P7+xpWXoNiK67xCepoChr8rqX-Z5EcNb-Bs3xhC+Uot2ruYg@mail.gmail.com>
In-Reply-To
<CAHd499C3n8DGuhxwajQbFrH+Fr8zHRA7sVjhG3yfSD5kKPSZsA@mail.gmail.com>
On Thu, Oct 1, 2015 at 9:43 AM, Robert Dailey <rcdailey.lists@gmail.com> wrote:
Show 15 quoted lines
> For convenient pushing of current branch, git supports this syntax:
>
> $ git push origin HEAD
>
> This will push your current branch up. However, is there such a
> shortcut for *deleting* the branch? The only goal here is to avoid
> having to type the branch name in the push command. Normally I rely on
> tab completion but we have tons of branches, all which start with some
> prefix mixed with numbers, so it becomes cumbersome to rely on tab
> completion. Ideally I'd like to be able to do:
>
> $ git push --delete origin HEAD
> $ git push origin :HEAD
>
> Is there a syntax like this available?
You can do
git push origin:<branchname>

but I don't believe HEAD is supported. It might be valuable to extend push to have a --delete option which would maybe be useful for those who didn't learn the full refspec syntax.

I don't think git push origin :HEAD makes too much sense, since that's on the remote side of a refspec, and you want it interpreted locally... I suppose it makes sense somewhat, but other refspecs with HEAD on the remote side of the refspec don't really make sense, where as HEAD always makes sense on the local side of the refspec.

Regards, Jake

Previous: Robert DaileyNext: Robert Dailey
Message 2 of 4 in “Convenient shortcut to push delete current branch?”
  1. Robert DaileyOct 1, 2015
  2. Jacob KellerOct 1, 2015
  3. Robert DaileyOct 1, 2015
  4. Mike RappazzoOct 2, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.