Page History

Turn Off History

Every few months, I get grumpy when my "git branch -a" command fills up the screen and it looks like there is a bunch of branches that are not being worked on, or that have been merged, or can otherwise be archived. So, I will move the "dead wood" branches from the branches to tags.

What gets bag-n-tagged

I just run a script that looks for branches that are more than 90 days old:

git for-each-ref --format='%(refname)' refs/remotes/origin | {
    exp=$(( $(date +'%s') - 7776000 ));
    while read ref; do
        if test ${exp} -gt $(git show -s --pretty=format:'%ct' $ref); then
            echo $ref
        fi
    done;
}

I then email htcondor-devel to politely ask if I can bag-n-tag the branches listed.

When a branch gets bag-n-tagged

I create a tag with the name of the branch, ending in "-tag". So branch "foo" will get tagged with tag "foo-tag". I run the following git commands
git tag -a -m "Bag-n-tag branch foo" foo-tag foo # To create the foo-tag tag
git push origin tag foo-tag # To publish the new tag
git push origin :refs/heads/foo # To delete the branch

How to resurrect a branch

If a branch is overzealously deleted, it is easy to restore. You may still have the old reference around, so you could run
git push origin refs/remotes/origin/foo:refs/heads/foo
to simply copy the old reference back to the condor repository

If you have only the tag, you can do the following

git branch foo foo-tag^{}
git push origin foo:foo
to restore the branch.