<> preface

Recently used git To manage a project , After reaching a certain stage , Stable code needs to be released into a release , After searching the data, we found that git The tag operation just meets my requirements , So write it down , Convenient later is to use the search .

<> purpose

Tags can be marked for versions at a point in time , Commonly used for release , That's exactly what I need , Push local tags to Github A Release edition , Easy to download and view .

<> Label classification

git There are two types of tags : Lightweight label and note label . Lightweight tags are references to submitted objects , The annotation tag is an independent object in the warehouse , Note label is recommended , You can also view the label information in the future .

<> create label

*
Create lightweight labels

$ git tag v0.2.0 -light

explain : You do not need to pass parameters to create a lightweight label , You can specify the label name directly .

*
Create note label

$ git tag -a v0.1.0 -m "release 0.1.0 version"

explain : When creating a note label , parameter -a Namely annotated Abbreviation for , Specifies the label type , Signature of attached bid . parameter m Specify label description , The description information is saved in the label object .

<> View label

*
Lists all tags for the current warehouse

$ git tag

*
List tags that match the pattern

$ git tag -l 'v0.1.*'

*
View label version information

$ git show v0.1.0

<> Switch label

*
The switch label is the same as the switch branch command

$ git checkout [tagname]

explain : After switching the label, it is on an empty branch , Namely "You are in ‘detached HEAD’ state."

<> delete a tap

*
When the label is wrongly typed or needs to be modified , You need to delete the label first , New label

$ git tag -d v0.1.2

explain : parameter -d Namely delete Abbreviation for , To delete the label specified after it .

<> Make up label

*
For assigned commit Label

$ git tag -a v0.1.0 49e0cd22f6bd9510fe65084e023d9c4316b446a6

explain : Labeling is not necessary HEAD above , It can also be typed in the previous version , This requires that you know the checksums of a submitted object , adopt git log Command acquisition .

<> Release label

*
take v0.1.0 Label submitted to git The server

$ git push origin v0.1.0

explain : Usual git push Label objects are not submitted to git The server , We need to do something explicit .

*
Submit all local tags to git The server

$ git push origin --tags

Technology
Daily Recommendation