Subject: Re: [wishlist] git branch -d -r remotename

From: Sam Vilain <[email-masked]>
Date: Mon, 19 Mar 2007 09:46:10 +1200

Junio C Hamano wrote:
>> Subject: [PATCH] git-remote: implement prune -c
>>
>> It would be nice to prune local refs which are irrelevant; add an
>> option to git-remote prune, with documentation.
>>     
>
> I do not understand what workflow you are assuming, so your use
> of the word "irrelevant" does not mean much to me.  I suspect
> other readers of the patch and documentation wouldn't find it
> clear in what situation this option is useful.
>   

Bad choice of words. What I mean is to delete all local refs which are
already reachable by a remote ref on the given remote.

> Perhaps you are thinking about this scenario?  I am only
> guessing because you are not clear enough:
>
> 	$ git clone
>         ... time passes ...
>         $ git checkout -b next origin/next
>         ... build, install, have fun ...
> 	$ git checkout master
>         ... time passes ...
>         $ git branch
>         ... notice that you do not hack on your copy of 'next'
>         ... and want to remove it
> 	$ git remote prune -c
>   

Yes, that's it. Or clean up the references you already pushed because
they are no longer of interest.

> In any case, are you checking irrelevancy?  What if your foo branch has
> more changes to be sent upstream?  Even when the remote has a
> bit older version doesn't your code remove yours?  For example,
> if you did this, instead of the above, what happens?
>
> 	$ git clone
>         ... time passes ...
>         $ git checkout -b next origin/next
>         ... build, install, have fun ...
> 	... find an opportunity to improve ...
>         $ edit
>         $ git commit ;# on your 'next'.
>         ... build, install, test ...
> 	$ git checkout master
>         ... time passes ...
>         $ git branch
>         ... notice that you do not hack on your copy of 'next' anymore,
>         ... and want to remove it
> 	$ git remote prune -c
>   

It doesn't do that because the head doesn't match any revision that was
given to us by `rev-list refs/remotes/foo/*`

> If the above is the usage scenario you are trying to help, then
> wouldn't it be helpful if you could also help removing 'my-next'
> in this slightly altered example?
>
> 	$ git clone
>         ... time passes ...
>         $ git checkout -b my-next origin/next
>         ... build, install, have fun ...
> 	$ git checkout master
>         ... time passes ...
>         $ git branch
>         ... notice that you do not hack on your copy of 'next'
>         ... which is 'my-next', and want to remove it
> 	$ git remote prune -c

Yes, the idea was to "sweep" all branches that were just local branches
of a remote and never worked on. This is most useful right now for
people switching from Cogito or old-style remotes, who have a lot of
branches that are remote tracking branches. Using this, they can just
set up a new remote, fetch and prune -c and be left in a tidy state.

Sam.