Because the project is too large, the partners are responsible for the corresponding module, some partners may be responsible for module A, some partners are responsible for module B. Therefore, we should put a tag on each code update to the production environment (when the master is merged), and then push it to the production environment. If the current version of the production environment has a bug, you can quickly fall back to the previous version of the tag.
Create a tag with a note
git tag -a V20210311 -m 'Update friend application message'
Copy the code
The above command successfully creates a local version of V20210311, and adds the note ‘update friend request information’, but for now this tag is only committed to the local Git repository.
2, synchronization to remote code base, remote push tag:
git push origin --tags
Copy the code
This allows us to push the local version to the remote repository.
3. When a partner clones a project from GitHub, it can be passedgit tag
Command to check which tags are currently available, as follows:
git tag
Copy the code
The version number of the tag is the date of submission, and you can use the update record in the readME document to determine which version you want to go back to
4, for example, I want to return to the V20210310 version, this time throughgit show V20210310
Command to view the corresponding version number, as follows:
git show V20210310
Copy the code
5, commit is the corresponding version number after the commit, and then passgit reset --hard b1014a2a4fef206bba50d970b7133c2de313b1b4
Command can return to the era of only the rights management module. As follows:
git reset --hard b1014a2a4fef206bba50d970b7133c2de313b1b4
Copy the code
The above command will help you jump between any version.
GIT removes both local and remote tags
With the tag V20210310, this tag has been synchronized to the remote, but now a problem has been found, so you need to withdraw the tag. Git command:
To delete a local tag:
git tag -d V20210310
Copy the code
Deleting a remote tag: after the local tag is deleted, the remote tag is deleted (an empty tag is pushed to the remote tag and the original value is overwritten with null value) 🙂
git push origin :refs/tags/V20210310
Copy the code
You can also use the –delete argument:
git push origin --delete tag V20210310
Copy the code