Jun
7

Git Workflows: Archiving Old Branches

Posted by Aaron West at 9:57 PM in ColdFusion, Git

I decided to take some time today to clean up old sprint branches that have been resting in Git unused. Some for well over a year. I had two goals I wanted to accomplish when trying to come up with a workflow. First, I wanted the list of branches that display with the command git branch -a (which I have conveniently aliased to just gb) to be shortened. Second, I didn't want to lose any of the commits part of old branches. Sure the commits were already merged into the master branch, but I didn't want to lose commit chain that was stored as branches.

My solution was to archive each branch as a tag then remove the branches from Git on my local machine as well as the Git origin server.

Continue Reading

Aaron West's Gravatar
About this post:

This entry was posted by Aaron West on June 7, 2011 at 9:57 PM. It was filed in the following categories: ColdFusion, Git. It has been viewed 76131 times and has 4 comments.

2 related blog entries

4 Responses to Git Workflows: Archiving Old Branches

  1. Nice approach Aaron! We have about 40 or so branches from our current build that have been merged and are going to hit production today. This came just in time since I will be archiving all those branches tomorrow to help clean up the repo some.

    Thanks for the post.

  2. wwwald

    Following this approach, what happens to the affected branches in other contributors' local repositories?

    Are they deleted in their repositories too, as soon as they pull or fetch?
    Or do they remain present, with the risk that they re-appear as soon as someone pushes the old branch to origin again?

  3. @wwwald - the answer to your question about the impact to the origin server was covered in the post itself.

    "My solution was to archive each branch as a tag then remove the branches from Git on my local machine as well as the Git origin server."

    Note: This post discusses tagging the state of the branch using "git tag" before archiving/deleting the branch. So developers can also restore the state of the branch by resetting/reverting to the SHA of the tag.

  4. wwwald

    Hi Aaron,

    I'm not wondering about the origin server, but rather the local repositories of other contributors, that also connect to the origin server.
    If the branches are archived on the origin server, they still may have the "unarchived" branches lingering around in their local repositories, right?
    Isn't there a risk of "archived" branches re-appearing as normal branches, as soon as one of the other contributors pushes it to the origin server again?