Today while doing cleanup and maintenance on some old Minecraft Mods code, I dedided to archive some of the branches.
Followed this steps I found on internet (But also added a “twist” when using Worktree):
1. Checkout to the master branch
git checkout master
If you’re using Worktree, navigate to the master directory instead of checking out the branch.
2. Create the tag
Lets say I want to archive the branch 1.16.5
as a tag called archive/1.16.5
.
git tag archive/1.16.5 1.16.5
3. Push the tag
git push origin archive/1.16.5
4. Remove the Worktree
git worktree remove 1.16.5
5. Delete the branch
git branch -D 1.16.5
6. Delete the remote branch
git push -d origin 1.16.5
And that did it for me. Now I have a tag called archive/1.16.5
that I can use to restore the branch.
To restore the branch I would do:
git checkout -b 1.16.5 archive/1.16.5
And that’s it! Hope this guide helps you!