[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Delete local git branch

From: Vadim Zeitlin
Subject: Re: [lmi] Delete local git branch
Date: Wed, 15 Jul 2020 17:22:29 +0200

On Wed, 15 Jul 2020 14:51:37 +0000 Greg Chicares <gchicares@sbcglobal.net> 

GC> On 2020-07-14 22:53, Vadim Zeitlin wrote:
GC> > On Tue, 14 Jul 2020 22:17:52 +0000 Greg Chicares 
<gchicares@sbcglobal.net> wrote:
GC> > 
GC> > GC> I was thinking of something like this:
GC> > GC>   git branch -d xanadu/census-view-only-grid
GC> > GC> or the same with a capital '-D' if necessary.
GC> > 
GC> >  Just for the record, this won't work because the argument here is not a
GC> > local branch and you can only delete local branches.
GC> True, '--delete' doesn't work, even with '--force'; but
GC> '--delete --remotes' does do what I want, which is only to
GC> prevent command-completion from picking the wrong thing:

 Ah, indeed, I didn't even know about "git branch -dr" combination, even
though this makes sense and it's less drastic than "git remote rm".

GC> Now I can use tab completion without that risk.

 I'm afraid I still don't understand what this risk actually is. Surely you
can't accidentally operate on xanadu/whatever instead of whatever? I.e.,
even if TAB completes to xanadu/something (which normally would require
typing at least "x" in the beginning already), could you really not notice
it somehow?

GC> Of course, another fetch brings it back:
GC> /opt/lmi/src/lmi[1]$git fetch xanadu                                        
GC> From https://github.com/vadz/lmi
GC>  * [new branch]          census-view-only-grid -> 
GC> /opt/lmi/src/lmi[0]$git branch --list --remotes |grep only-                 
GC>   xanadu/census-view-only-grid
GC> but I do that rarely.

 I'd recommend doing this relatively often because having outdated local
information about the remote repository can be quite confusing.

GC> >  Worse, Git uses garbage collector instead of removing unused commits
GC> > immediately, so unless you use some cryptic commands (git-fsck etc), you
GC> > will still have the old commits somewhere in your .git/objects directory,
GC> > even if you won't have symbolic references to them any longer.
GC> Okay, but I don't care about deleting the contents in .git/objects;
GC> I only want to get rid of the "tag" to avoid command-completion snafus.

 Just to establish some vocabulary, Git calls them "references", or "refs".
"Tags" are something quite different.


Attachment: pgpupofxLnFiL.pgp
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]