[Top][All Lists]

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

[lmi] Delete local git branch [Was: PATCH: wxGrid-based census view]

From: Greg Chicares
Subject: [lmi] Delete local git branch [Was: PATCH: wxGrid-based census view]
Date: Wed, 15 Jul 2020 14:51:37 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

On 2020-07-14 22:53, Vadim Zeitlin wrote:
> On Tue, 14 Jul 2020 22:17:52 +0000 Greg Chicares <gchicares@sbcglobal.net> 
> wrote:
> GC> I was thinking of something like this:
> GC>   git branch -d xanadu/census-view-only-grid
> GC> or the same with a capital '-D' if necessary.
>  Just for the record, this won't work because the argument here is not a
> local branch and you can only delete local branches.

True, '--delete' doesn't work, even with '--force'; but
'--delete --remotes' does do what I want, which is only to
prevent command-completion from picking the wrong thing:

> GC> As long as I have a local copy of that remote branch, there's
> GC> a chance that I'll type 'git some-command census-view<Tab>'
> GC> and do something regrettable.

/opt/lmi/src/lmi[0]$git branch --list --remotes |grep only-
/opt/lmi/src/lmi[0]$git branch --delete --remotes xanadu/census-view-only-grid
Deleted remote-tracking branch xanadu/census-view-only-grid (was a81ff3077).
/opt/lmi/src/lmi[0]$git branch --list --remotes |grep only-                   

Now I can use tab completion without that risk.

Of course, another fetch brings it back:

/opt/lmi/src/lmi[1]$git fetch xanadu                                          
>From https://github.com/vadz/lmi
 * [new branch]          census-view-only-grid -> xanadu/census-view-only-grid
/opt/lmi/src/lmi[0]$git branch --list --remotes |grep only-                   

but I do that rarely.

>  Worse, Git uses garbage collector instead of removing unused commits
> immediately, so unless you use some cryptic commands (git-fsck etc), you
> will still have the old commits somewhere in your .git/objects directory,
> even if you won't have symbolic references to them any longer.

Okay, but I don't care about deleting the contents in .git/objects;
I only want to get rid of the "tag" to avoid command-completion snafus.

reply via email to

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