Skip to content

Instantly share code, notes, and snippets.

@johngian
Last active July 4, 2022 09:16
Show Gist options
  • Save johngian/f0c2441975889c03a26c271e9ad80806 to your computer and use it in GitHub Desktop.
Save johngian/f0c2441975889c03a26c271e9ad80806 to your computer and use it in GitHub Desktop.
Archive local branches
git for-each-ref --format='%(refname:short)' refs/heads/ | grep -v -E 'production|master|main' | xargs -I {} git tag archive/{}/$(date +%s)
git for-each-ref --format='%(refname:short)' refs/heads/ | grep -v -E 'production|master|main' | xargs -I {} git branch -D {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment