From: Junio C Hamano Date: Fri, 19 Jul 2013 15:08:57 GMT Subject: Re: [RFC] Delete current branch Message-ID: <7vr4euy4c6.fsf@alter.siamese.dyndns.org> In-Reply-To: Ramkumar Ramachandra writes: > Many of my ideas turn out to be really stupid, and I need to throw > away my feature branch. So, I find myself doing this often: > > # on branch menuconfig-jk > $ git checkout master > $ git branch -D > # er, what was the branch name again? > $ git checkout - > # Ah > $ git checkout master > $ git branch -D menuconfig-jk > > So, I scripted it for myself. Perhaps we should get the functionality > in core as `git branch -Dc` (c for "current"; or something)? What branch will I be on after doing that? Detached at that branch? > Also, perhaps a `git describe -` corresponding to `git checkout -` Did you know that the general way to spell the branch previously you were on is "@{-1}" and "checkout -" is an ugly special case that is possible only because "checkout" does not happen to take a "-" as a valid argument that means something else (like the more usual "read from standard input")? Perhaps $ git branch -D @{-1} would have worked without and everything that follows.