How can I archive git branches?
Solution 1:
I believe the proper way to do this is to tag the branch. If you delete the branch after you have tagged it then you've effectively kept the branch around but it won't clutter your branch list.
If you need to go back to the branch just check out the tag. It will effectively restore the branch from the tag.
To archive and delete the branch:
git tag archive/<branchname> <branchname>
git branch -d <branchname>
To restore the branch some time later:
git checkout -b <branchname> archive/<branchname>
The history of the branch will be preserved exactly as it was when you tagged it.
Solution 2:
Jeremy's answer is correct in principle, but IMHO the commands he specifies are not quite right.
Here's how to archive a branch to a tag without having to checkout the branch (and, therefore, without having to checkout to another branch before you can delete that branch):
> git tag archive/<branchname> <branchname>
> git branch -D <branchname>
And here's how to restore a branch:
> git checkout -b <branchname> archive/<branchname>