Boost logo

Boost :

Subject: Re: [boost] [git] Are we free to delete old branches?
From: Dave Abrahams (dave_at_[hidden])
Date: 2013-12-08 16:47:03


Beman Dawes <bdawes_at_[hidden]> writes:

> On Sun, Dec 8, 2013 at 7:23 AM, Daniel James <daniel_at_[hidden]> wrote:
>
>> On 8 December 2013 12:09, John Maddock <john_at_[hidden]> wrote:
>> > I notice most of my stuff is littered with old branches, most of which
>> have
>> > nothing to do with the library in question (or are even related to old
>> CVS
>> > branches).
>> >
>> > Are we free to delete these old branches without effecting any other lib?
>> >
>> > Is it a good/bad idea? Seems to be recommended practice in Git to delete
>> > branches once they're no longer needed?
>>
>> David Abrahams suggested creating 'hidden' refs for old branches and
>> then deleting them.
>>
>> I just tried this in unordered:
>>
>> git update-ref refs/hidden/svn-branches/b2 origin/svn-branches/b2
>> git push origin 'refs/hidden/*'
>> git push origin :svn-branches/b2
>>
>> I think it worked okay - my local mirror picked up the hidden ref.
>> Does this look right? It shouldn't be too hard to script.
>>
>
> I tried to read http://git-scm.com/book/en/Git-Internals-Git-References to
> educate myself enough to understand what you (and Dave) are talking about,
> but my eyes glazed over within a few sentences.
>
> Could you please give a very simple sentence describing what a "hidden ref"
> is and what is accomplished by creating one?

Branches and tags are refs (seen in .git/refs/heads and .git/refs/tags
respectively). They can be referred to by their shorthand name
(e.g. "master") or their fully-elaborated path ("refs/heads/master")

A "hidden ref" is a branch with a non-standard path, under refs/ but not
under refs/heads/

So, to hide a remote branch, you might:

  git push origin <thebranch>:refs/hidden/<thebranch> # create non-std ref
  git push origin :<thebranch> # delete the old ref

There are various tools around for making this kind of stuff easier,
e.g., I have this in my .gitconfig for *local* hiding:

[alias]
        hide = "!f() { git update-ref refs/hidden/$1 $1 && git branch -D $1; }; f"
        unhide = "!f() { git branch $1 && git update-ref $1 refs/hidden/$1; }; f"
        hidden = "!f() { git show-ref | grep hidden; }; f"

Also, see .https://github.com/csonto/git-private

HTH,
Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk