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

Re: [PATCH] branch: implement shortcut to delete last branch

From
Jeff King <peff@peff.net>
Date
Mar 23, 2018, 08:56 UTC
Message-ID
<20180323085636.GA24416@sigill.intra.peff.net>
In-Reply-To
<1521770966-18383-1-git-send-email-p@aaronjgreenberg.com>
On Fri, Mar 23, 2018 at 02:09:25AM +0000, Aaron Greenberg wrote:
Show 21 quoted lines
> This patch gives git-branch the ability to delete the previous
> checked-out branch using the "-" shortcut. This shortcut already exists
> for git-checkout, git-merge, and git-revert. One of my common workflows
> is to do some work on a local topic branch and push it to a remote,
> where it gets merged in to 'master'. Then, I switch back to my local
> master, fetch the remote master, and delete the previous topic branch.
> 
> $ git checkout -b topic-a
> $ # Do some work...
> $ git commit -am "Implement feature A"
> $ git push origin topic-a
> 
> # 'origin/topic-a' gets merged into 'origin/master'
> 
> $ git checkout master
> $ git branch -d topic-a
> $ # With this patch, a user could simply type
> $ git branch -d -
> 
> I think it's a useful shortcut for cleaning up a just-merged branch
> (or a just switched-from branch.)

I don't use "-" myself, but I can see how this would be useful. Do note that in a discussion last year there was some hesitation about allowing "-" for destructive commands:

  https://public-inbox.org/git/vpqh944eof7.fsf@anie.imag.fr/
I don't really have a strong opinion either way.

The details in this cover letter probably should go into the commit message. The diff itself looks OK (the assumption of a 7-char abbreviation in the test is a little gross, but I see you're just following existing convention in the file).

-Peff
Previous: Aaron GreenbergNext: Jeff King
Message 3 of 9 in “branch: implement shortcut to delete last branch”
  1. branch: implement shortcut to delete last branchAaron Greenberg, Mar 23, 2018
  2. branch: implement shortcut to delete last branchAaron Greenberg, Mar 23, 2018
  3. Jeff KingMar 23, 2018
  4. Jeff KingMar 23, 2018
  5. branch: implement shortcut to delete last branchAaron Greenberg, Mar 23, 2018
  6. branch: implement shortcut to delete last branchAaron Greenberg, Mar 23, 2018
  7. Jeff KingMar 26, 2018
  8. git@matthieu-moy.frMar 26, 2018
  9. Junio C HamanoMar 26, 2018

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.