This is a quick way to archive a git branch. Maybe you do not use the code anymore and the branch is cluttering the repo but for backup or historical reasons you need to keep it somewhere.
The first thing is to checkout to the branch
$ git checkout my-branch
Then create a new tag. I use the format archive/branch-{name}
$ git tag archive/branch-my-branch
Now we can upload the tags to Github or Gitlab
$ git push origin --tags
And delete the branch from local and origin repos.
Be sure to be in another branch like master
$ git checkout master
Then
$ git branch -d my-branch
$ git push origin :my-branch
If you need to delete the tag (an all the branch backup) from local
$ git tag -d archive/branch-my-branch
Or from origin
$ git push --delete origin archive/branch-my-branch
This will erase all tagged branch data though. Please be careful.
Top comments (2)
The title is quite confusing because if I recall, git has an 'archive' command which exports to a zip π.
lol xd. well
git
happens, I don't know if I should update the title since the url would maintain I guess.