Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save hhebig/664fcc4456b68bccf90f80f0de70b2d6 to your computer and use it in GitHub Desktop.

Select an option

Save hhebig/664fcc4456b68bccf90f80f0de70b2d6 to your computer and use it in GitHub Desktop.
Procedure to archive git branches.

How to prune unwanted git branches

  1. Tag the unwanted branch:
git tag archive/sprintjuly2010 sprintjuly2010
  1. Delete the branch:
git branch -d sprintjuly2010
  1. Push the branch deletion to origin:
git push origin :sprintjuly2010
  1. Push the new tag to origin:
git push --tags
  1. Restore a deleted branch from a tag:
git checkout -b sprintjuly2010 archive/sprintjuly2010
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment