Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction to Git Foundation (6) Git tags and aliases

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Label

Git can tag a submission in history to show its importance, and people usually use this feature to mark the release node (v1.0, etc.)

View label

Git tag # lists labels in alphabetical order

Git tag-l 'v1.8.5labels'# lists tags that have begun with v1.8.5

V1.8.5

V1.8.5.1

V1.8.5.2

V1.8.5.3

V1.8.5.4

V1.8.5.5

Create label

Commonly used tags: lightweight tags (lightweight) and note tags (annotated)

Lightweight tag: much like a branch that will not change, it is just a reference to a specific submission

Note tag: a complete object stored in the Git database that contains the tagger's name, email, date, tag information, and can be signed and verified using GPG. It is usually recommended to create a note tag.

Note label

Git tag-a v1.0.0-m 'version 1.0.0'

Git tag

V1.0.0

-m: specify a piece of information stored in the tag. If you do not use the-m option, Git will run the editor and ask you to enter the information.

Git show v1.0.0 # View tag information and its corresponding submission information

Tag v1.0.0

Tagger: huyuan

Date: Sun Oct 22 16:20:28 2017 + 0800

Version 1.0.0

Commit 000b2e58dccc803407885057433cc5fc40dc1d1d

Author: huyuan

Date: Sun Oct 22 16:20:07 2017 + 0800

Test-gat

Diff-git a/a.py b/a.py

Index e69de29..d00491f 100644

-a/a.py

+ b/a.py

@ @-0pen 0 + 1 @ @

+ 1

The output shows the tagger's information, the date and time of the tag, the note information, and then the specific submission information.

Lightweight label

Lightweight tags essentially store submissions and checksums in a file without saving any other information

Git tag v1.0.0.5 # create a lightweight label

Git show v1.0.0.5 # View label

Commit 000b2e58dccc803407885057433cc5fc40dc1d1d

Author: huyuan

Date: Sun Oct 22 16:20:07 2017 + 0800

A

Diff-git a/a.py b/a.py

Index e69de29..d00491f 100644

-a/a.py

+ b/a.py

@ @-0pen 0 + 1 @ @

+ 1

Tag past submissions:

Git log-- pretty=oneline-- abbrev-commit # View historical version information

B5e309e version-4

1008c08 version-3

000b2e5 versino-2

E4c1d11 version-1

Git tag-a v1.2.0 000b2e5 # tags the submission of versino-2

Shared label

By default, git push does not send the tag to the remote warehouse. After creating the tag, you must explicitly push the tag to the remote warehouse.

Git push origin v1.2.0 # push v1.2.0 to the remote warehouse

Git push origin-tags # pushes all tags that are not on the remote warehouse to the remote warehouse

Git alias

Use the git config command to set an alias for each command

Git config-- global alias.ci commit # definition alias

Git config-global alias.st status # alias. Alias commant

Git config-- global alias.last 'log-1 HEAD'

Git commit equals git ci git status equals git st git last to view the last submitted information

Git config-global alias.unstage 'reset HEAD -'

Then git reset HEAD-- fileA equals git unstage fileA

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report