git learning Notes - Create Label

Playing tag in Git is very simple, first of all, to tag the switch to branch:

$ git branch
* dev
  master
$ git checkout master
Switched to branch 'master'

Then, knock command git tag <name>you can play a new label:

$ git tag v1.0

You can use the command git tagto see all tags:

$ git tag
v1.0

The default labels are playing in the commit latest submitted. Sometimes, if you forget to tag, for example, it is now Friday, but did not play in Monday's fight should be a label, how do?

The method is to find the commit id history submitted, and then marked on it:

$ git log --pretty=oneline --abbrev-commit
12a631b (HEAD -> master, tag: v1.0, origin/master) merged bug fix 101 4c805e2 fix bug 101 e1e9c68 merge with no-ff f52c633 add merge cf810e4 conflict fixed 5dc6824 & simple 14096d0 AND simple b17d20e branch test d46f35e remove test.txt b84166e add test.txt 519219b git tracks changes e43a48b understand how stage works 1094adb append GPL e475afc add distributed eaadf4e wrote a readme file 

Let's say you want to add mergesubmit this to play tag, which corresponds to commit id Shi f52c633, typing the command:

$ git tag v0.9 f52c633

Then the command git tagView Tags:

$ git tag
v0.9
v1.0

Note that the label is not listed in chronological order, but in alphabetical order. You can git show <tagname>view the label information:

$ git show v0.9
commit f52c63349bc3c1593499807e5c8e972b82c8f286 (tag: v0.9) Author: Michael Liao <[email protected]> Date: Fri May 18 21:56:54 2018 +0800 add merge diff --git a/readme.txt b/readme.txt ... 

You can see, v0.9it is indeed playing in add mergethis submission.

You can also create a label with instructions, with -athe specified tag name, -mspecify the caption:

$ git tag -a v0.1 -m "version 0.1 released" 1094adb 

Command git show <tagname>can see the caption:

$ git show v0.1
tag v0.1
Tagger: Michael Liao <[email protected]>
Date:   Fri May 18 22:48:43 2018 +0800

version 0.1 released

commit 1094adb7b9b3807259d8cb349e7df1d4d6477073 (tag: v0.1)
Author: Michael Liao <[email protected]>
Date:   Fri May 18 21:06:15 2018 +0800

    append GPL

diff --git a/readme.txt b/readme.txt
...
 Note: Always label and a commit hook. If the commit both appear in the master branch, he appeared in the dev branch, you can see the labels on these two branches.
 

summary

  • Command git tag <tagname>is used to create a new label, the default is HEAD, you can specify a commit id;

  • Command git tag -a <tagname> -m "blablabla..."can specify the label information;

  • Commands git tagcan view all tags.

Guess you like

Origin www.cnblogs.com/saryli/p/11369210.html