I am looking at starting a v2 of my code and wanted to archive my v1 code in the same repo at a new branch so that I could have a fresh start in my repo at the origin.
What's the best practices for this or approaches for this?
Answer : add a tag for your V1 of your code and after that work on V2
Best and easiest way to have multiple versions (Either for releasing a stable version or changing other things in next versions) is to use git tag
command
you can create tags for GitHub by either using:
To create a tag on your current branch, run this:
git tag <tagname>
If you want to include a description with your tag, add -a
to create an annotated tag:
git tag <tagname> -a
This will create a local
tag with the current state of the branch you are on. When pushing to your remote repo, tags are NOT included by default. You will need to explicitly say that you want to push your tags to your remote repo:
git push origin --tags
From the official Linux Kernel Git documentation for git push
:
--tags
All refs under refs/tags are pushed, in addition to refspecs explicitly listed on the command line.
Or if you just want to push a single tag:
git push origin <tag>
See also How do you push a tag to a remote repository using Git? for more details about that syntax above.
I would create a new release, using the GitHub cli gh
tool gh release create
gh release create v1.0.0 --notes "v1"
That would create/push the tag for you, allowing you to go-on on your main branch for v2.
That means: You don't need origin/master
to a new branch right away, only a tag from which you can create a v1_fixes
branch later, if you have to maintain v1.