git 列出標簽_Git標簽介紹:如何在Git中列出,創建,刪除和顯示標簽

git 列出標簽

Tagging lets developers mark important checkpoints in the course of their projects' development. For instance, software release versions can be tagged. (Ex: v1.3.2) It essentially allows you to give a commit a special name(tag).

通過標記,開發人員可以在項目開發過程中標記重要的檢查點。 例如,可以標記軟件發行版本。 (例如:v1.3.2)從本質上講,它可以使提交具有特殊的名稱(標記)。

To view all the created tags in alphabetical order:

要按字母順序查看所有創建的標簽:

git tag

To get more information on a tag:

要獲取有關標簽的更多信息:

git show v1.4

There are two types of tags:

標簽有兩種類型:

Annotated

帶注解

git tag -a v1.2 -m "my version 1.4"

Lightweight

輕巧的

git tag v1.2

They differ in the way that they are stored.These create tags on your current commit.

它們的存儲方式不同。這些在當前提交時創建標記。

Incase, you’d like to tag a previous commit specify the commit ID you’d like to tag:

如果要標記上一個提交,請指定要標記的提交ID:

git tag -a v1.2 9fceb02

The tags names may be used instead of commit IDs while checking out and pushing commits to a remote repo.

在簽出并將推送推送到遠程存儲庫時,可以使用標簽名稱代替提交ID。

更多信息: (More Information:)

  • Git documentation: Documentation

    Git文檔: 文檔

  • Git Tagging Chapter: Book

    Git標簽章節: 書

You can list all available tags in a project with the git tag command (nate that they will appear in alphabetical order):

您可以使用git tag命令列出項目中所有可用的標簽(它們將以字母順序顯示):

$ git tag
v1.0
v2.0
v3.0

This way of listing tags is great for small projects, but greater projects can have hundreds of tags, so you may need to filter them when searching for an important point in the history. You can find tags containing specific characters adding an -l to the git tag command:

這種列出標簽的方式非常適合小型項目,但是較大的項目可以包含數百個標簽,因此在搜索歷史中的重要點時可能需要過濾它們。 您可以找到包含特定字符的git tag ,在git tag命令中添加-l

$ git tag -l "v2.0*"
v2.0.1
v2.0.2
v2.0.3
v2.0.4

建立標簽 (Create a tag)

You can create two type of tags: annotated and lightweight. They first ones are compete objects in GIT database: they are checksummed, requiere a message (like commits) and store other important data such as name, email and date. On the other hand, lightweight tags don require a mesage or store other data, working just as a pointer to a specific point in the project.

您可以創建兩種類型的標簽:帶注釋的標簽和輕量標簽。 它們中的第一個是GIT數據庫中的競爭對象:對它們進行校驗和,要求一條消息(例如提交)并存儲其他重要數據,例如名稱,電子郵件和日期。 另一方面,輕量級標簽不需要消息或存儲其他數據,就像指向項目中特定點的指針一樣。

創建帶注釋的標簽 (Create an annotated tag)

To create an anotated tag, add -a tagname -m "tag message" to the git tag command:

要創建帶注釋的標簽,請在git tag命令中添加-a tagname -m "tag message"

$ git tag -a v4.0 -m "release version 4.0"
$ git tag
v1.0
v2.0
v3.0
v4.0

As you can see, the -a specifies that you are creating an annotated tag, after comes the tag name and finally, the -m followed by the tag message to store in the Git database.

如您所見, -a指定您要創建帶注釋的標簽,標簽名稱后面是-a ,最后是-m后跟標簽消息以存儲在Git數據庫中。

創建一個輕量級標簽 (Create a lightweight tag)

Lightweight tags contain only the commit checksum (no other information is stored). To create one, just run the git tag command without any other options (the -lw characters at the end of the name are used to indicate lightweight tags, but you can mark them as you like):

輕量級標簽僅包含提交校驗和(不存儲其他信息)。 要創建一個,只需運行git tag命令,不帶任何其他選項(名稱末尾的-lw字符用于表示輕量級標簽,但您可以根據需要對其進行標記):

$ git tag v4.1-lw
$ git tag
v1.0
v2.0
v3.0
v4.0
v4.1-lw

This time you didn’t specify a message or other relevant data, so the tag contains only the refered commit’s checksum.

這次您沒有指定消息或其他相關數據,因此標簽僅包含引用的提交的校驗和。

查看標簽的數據 (View tag’s data)

You can run the git show command to view the data stored in a tag. In the case of annotated tags, you’ll see the tag data and the commit data:

您可以運行git show命令來查看存儲在標簽中的數據。 對于帶注釋的標簽,您將看到標簽數據和提交數據:

$ git show v4.0
tag v4.0
Tagger: John Cash <john@cash.com>
Date:   Mon Sat 28 15:00:25 2017 -0700release version 4.0commit da43a5fss745av88d47839247990022a98419093
Author: John Cash <john@cash.com>
Date:   Fri Feb 20 20:30:05 2015 -0700finished details

If the tag you are watching is a lightweight tag, you’ll only see the refered commit data:

如果您正在查看的標簽是輕量級標簽,則您只會看到引用的提交數據:

$ git show v1.4-lw
commit da43a5f7389adcb9201ab0a289c389ed022a910b
Author: John Cash <john@cash.com>
Date:   Fri Feb 20 20:30:05 2015 -0700finished details

標記舊提交 (Tagging old commits)

You can also tag past commits using the git tag commit. In order to do this, you’ll need to specify the commit’s checksum (or at least a part of it) in the command’s line.

您還可以使用git標簽commit標記過去的提交。 為此,您需要在命令行中指定提交的校驗和(或至少校驗和的一部分)。

First, run git log to find out the required commit’s checksum:

首先,運行git log找出所需提交的校驗和:

$ git log --pretty=oneline
ac2998acf289102dba00823821bee04276aad9ca added products section
d09034bdea0097726fd8383c0393faa0072829a7 refactorization
a029ac120245ab012bed1ca771349eb9cca01c0b modified styles
da43a5f7389adcb9201ab0a289c389ed022a910b finished details
0adb03ca013901c1e02174924486a08cea9293a2 small fix in search textarea styles

When you have the checksum needed, add it at the end of the tag creation line:

擁有所需的校驗和后,將其添加到標簽創建行的末尾:

$ git tag -a v3.5 a029ac

You’ll see the tag was correctly added running git tag:

您會看到標簽已正確添加,并運行git tag

$ git tag
v1.0
v2.0
v3.0
v3.5
v4.0
v4.1-lw

推送標簽 (Push tags)

Git does’t push tags by default when you run the git push command. So, to succesfully push a tag to a server you’ll have to git push origin command:

默認情況下,當您運行git push命令時,Git不會推送標簽。 因此,要成功將標簽推送到服務器,您必須使用git push origin命令:

$ git push origin v4.0
Counting objects: 14, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (18/18), 3.15 KiB | 0 bytes/s, done.
Total 18 (delta 4), reused 0 (delta 0)
To git@github.com:jcash/gitmanual.git* [new tag]         v4.0 -> v4.0

You can also use the --tags option to add multiple tags at once with the git push origin command:

您還可以使用--tags選項通過git push origin命令一次添加多個標簽:

$ git push origin --tags
Counting objects: 1, done.
Writing objects: 100% (1/1), 160 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
To git@github.com:jcash/gitmanual.git* [new tag]         v4.0 -> v4.0* [new tag]         v4.1-lw -> v4.1-lw

簽出標簽 (Checking out Tags)

You can use git checkout to checkout to a tag like you would normally do. But you need to keep in mind that this would result a detached HEAD state.

您可以git checkout使用git checkout簽出到標簽。 但是您需要記住,這將導致HEAD狀態分離

$ git checkout v0.0.3
Note: checking out 'v0.0.3'.You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

刪除標簽 (Deleting a Tag)

You may find a situation were you want to delete a certain tag. There’s a very useful command for this situations:

如果您要刪除某個標簽,可能會發現一種情況。 對于這種情況有一個非常有用的命令:

$ git tag --delete v0.0.2
$ git tag
v0.0.1
v0.0.3
v0.0.4

更多信息 (More Information)

  • Git Pro - Tagging Basics

    Git Pro-標記基礎

  • Git Pro - Documentation

    Git Pro-文檔

  • Git HowTo

    Git HowTo

  • Git tip: Tags

    Git提示:標簽

  • Creating a tag

    創建標簽

資料來源 (Sources)

Git documentation: tags

Git文檔: 標簽

翻譯自: https://www.freecodecamp.org/news/git-tag-explained-how-to-add-remove/

git 列出標簽

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/390650.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/390650.shtml
英文地址,請注明出處:http://en.pswp.cn/news/390650.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

leetcode 278. 第一個錯誤的版本(二分)

題目 你是產品經理&#xff0c;目前正在帶領一個團隊開發新的產品。不幸的是&#xff0c;你的產品的最新版本沒有通過質量檢測。由于每個版本都是基于之前的版本開發的&#xff0c;所以錯誤的版本之后的所有版本都是錯的。 假設你有 n 個版本 [1, 2, …, n]&#xff0c;你想找…

騰訊哈勃_用Python的黑客統計資料重新審視哈勃定律

騰訊哈勃Simple OLS Regression, Pairs Bootstrap Resampling, and Hypothesis Testing to observe the effect of Hubble’s Law in Python.通過簡單的OLS回歸&#xff0c;配對Bootstrap重采樣和假設檢驗來觀察哈勃定律在Python中的效果。 In this post, we will revisit Hub…

JAVA中動態編譯的簡單使用

一、引用庫 pom文件中申明如下&#xff1a; <dependencies><!-- https://mvnrepository.com/artifact/junit/junit --><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version><…

程序員實用小程序_我從閱讀《實用程序員》中學到了什么

程序員實用小程序In short: old but gold.簡而言之&#xff1a;古老而又黃金。 Published in 1999, The Pragmatic Programmer is a book about how to become a Pragmatic Programmer. Which really means a ‘Good Programmer’. 《實用程序員》于1999年出版&#xff0c;是一…

leetcode 5786. 可移除字符的最大數目(二分法)

題目 給你兩個字符串 s 和 p &#xff0c;其中 p 是 s 的一個 子序列 。同時&#xff0c;給你一個元素 互不相同 且下標 從 0 開始 計數的整數數組 removable &#xff0c;該數組是 s 中下標的一個子集&#xff08;s 的下標也 從 0 開始 計數&#xff09;。 請你找出一個整數…

如何使用Picterra的地理空間平臺分析衛星圖像

From April-May 2020, Sentinel-Hub had organized the third edition of their custom script competition. The competition was organized in collaboration with the Copernicus EU Earth Observation programme, the European Space Agency and AI4EO consortium.從2020年…

df -l查看本地文件系統

df -l, --locallimit listing to local file systems 轉載于:https://www.cnblogs.com/jonathanyue/p/9301222.html

在Packet Tracer中路由器靜態路由配置

實驗目標&#xff1a;<1>掌握靜態路由的配置方法和技巧<2>掌握通過靜態路由方式實現網絡的連通性<3>熟悉廣域網線纜的鏈接方式技術原理&#xff1a;<1>路由器屬于網絡層設備&#xff0c;能夠根據IP包頭的信息&#xff0c;選擇一條最佳路徑&#xff0c;…

python示例_帶有示例的Python功能指南

python示例Python函數簡介 (Introduction to Functions in Python) A function allows you to define a reusable block of code that can be executed many times within your program.函數允許您定義一個可重用的代碼塊&#xff0c;該代碼塊可以在程序中多次執行。 Function…

leetcode 852. 山脈數組的峰頂索引(二分查找)

題目 符合下列屬性的數組 arr 稱為 山脈數組 &#xff1a; arr.length > 3 存在 i&#xff08;0 < i < arr.length - 1&#xff09;使得&#xff1a; arr[0] < arr[1] < … arr[i-1] < arr[i] arr[i] > arr[i1] > … > arr[arr.length - 1] 給你由…

hopper_如何利用衛星收集的遙感數據輕松對蚱hopper中的站點進行建模

hopper建筑學與數據科學 (Architectonics and Data Science) Understanding the site and topography are crucial first step of any architectural project. Site modelling can become very daunting, expensive, or just cumbersome, often having to use various software…

Git 倉庫代碼遷移步驟記錄

遷移遠程倉庫 // 克隆舊倉庫鏡像 git clone --mirror [oldRepoUrl]// 添加新倉庫地址 cd the_repo git remote add [remoteName] [newRepoUrl]// 推到新的遠程庫 git push -f --tags [remoteName] refs/heads/*:refs/heads/* 復制代碼中括號中的名稱需根據自己項目需求替換 更新…

TensorFlow MNIST 入門 代碼

其實就是按照TensorFlow中文教程的內容一步步跟著敲的代碼。 不過在運行代碼的時候遇到代碼中加載不到MNIST數據資源&#xff0c;似乎是被墻了&#xff08;(⊙﹏⊙)b&#xff09; 于是自己手動下載了數據包&#xff0c;放到 MNIST_data/ 文件夾下&#xff0c;代碼就能正常運轉了…

JavaScript中的基本表單驗證

In the past, form validation would occur on the server, after a person had already entered in all of their information and pressed the submit button. 過去&#xff0c;表單驗證會在一個人已經輸入了所有信息并按下“提交”按鈕之后在服務器上進行。 If the informa…

leetcode 877. 石子游戲(dp)

題目 亞歷克斯和李用幾堆石子在做游戲。偶數堆石子排成一行&#xff0c;每堆都有正整數顆石子 piles[i] 。 游戲以誰手中的石子最多來決出勝負。石子的總數是奇數&#xff0c;所以沒有平局。 亞歷克斯和李輪流進行&#xff0c;亞歷克斯先開始。 每回合&#xff0c;玩家從行的…

es6的Map()構造函數

普通的object對象是鍵值對的集合&#xff0c;但對于它的鍵卻有著嚴苛的要求&#xff0c;必須是字符串&#xff0c;這給我們平時帶來很多的不方便 Map函數類似于對象&#xff0c;但它是一個更加完美的簡直對集合&#xff0c;鍵可以是任意類型 set()方法可以向map實例對象中添加一…

mac里打開隱藏的 library文件夾

打開Finder&#xff0c;單擊【前往】&#xff0c;此時只有按住【option】鍵&#xff0c;就能出現“資源庫”的選項。 或者鍵入 ~/Library 進入 轉載于:https://www.cnblogs.com/laolinghunWbfullstack/p/8888124.html

華為開源構建工具_為什么我構建了用于大數據測試和質量控制的開源工具

華為開源構建工具I’ve developed an open-source data testing and a quality tool called data-flare. It aims to help data engineers and data scientists assure the data quality of large datasets using Spark. In this post I’ll share why I wrote this tool, why …

字號與磅值對應關系_終極版式指南:磅值,大寫與小寫,Em和En破折號等

字號與磅值對應關系Typography is a field that deals with the written word and how letters and characters are presented.印刷術是處理文字以及字母和字符的顯示方式的領域。 The same letters can be styled in different ways to convey different emotions. And there…

leetcode 65. 有效數字(正則表達式)

題目 有效數字&#xff08;按順序&#xff09;可以分成以下幾個部分&#xff1a; 一個 小數 或者 整數 &#xff08;可選&#xff09;一個 ‘e’ 或 ‘E’ &#xff0c;后面跟著一個 整數 小數&#xff08;按順序&#xff09;可以分成以下幾個部分&#xff1a; &#xff08;…