There’s an answer on SO that I like better:

git tag archive/<branchname> <branchname>
 git branch -D <branchname>
 git branch -d -r origin/<branchname>
 git push --tags
 git push origin :<branchname>


[Old content]

git tag archive/{branch name} {branchname}

git branch -D {branchname}

To later restore the branch, if needed:

git checkout -b {branchname} archive/{branchname}

Alternative options: to archive in a different repository or to use git-bundle.