Git-tag-operation
提供:Dev Guides
Git-タグ操作
タグ操作により、リポジトリ内の特定のバージョンに意味のある名前を付けることができます。 トムとジェリーがプロジェクトコードにタグを付けて、後で簡単にアクセスできるようにするとします。
タグを作成する
*git tag* コマンドを使用して、現在のHEADにタグを付けましょう。 トムは、-aオプションでタグ名を提供し、-mオプションでタグメッセージを提供します。
tom@CentOS project]$ pwd
/home/tom/top_repo/project
[tom@CentOS project]$ git tag -a 'Release_1_0' -m 'Tagged basic string operation code' HEAD
特定のコミットにタグを付ける場合は、HEADポインターの代わりに適切なCOMMIT IDを使用します。 トムは次のコマンドを使用して、タグをリモートリポジトリにプッシュします。
[tom@CentOS project]$ git push origin tag Release_1_0
上記のコマンドは、次の結果を生成します-
Counting objects: 1, done.
Writing objects: 100% (1/1), 183 bytes, done.
Total 1 (delta 0), reused 0 (delta 0)
To [email protected]:project.git
* [new tag]
Release_1_0 −> Release_1_0
タグを表示
トムはタグを作成しました。 これで、Jerryは、-lオプションを指定したGit tagコマンドを使用して、使用可能なすべてのタグを表示できます。
[jerry@CentOS src]$ pwd
/home/jerry/jerry_repo/project/src
[jerry@CentOS src]$ git pull
remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (1/1), done.
From git.server.com:project
* [new tag]
Release_1_0 −> Release_1_0
Current branch master is up to date.
[jerry@CentOS src]$ git tag -l
Release_1_0
Jerryは、Gitのshowコマンドの後にタグ名を使用して、タグの詳細を表示します。
[jerry@CentOS src]$ git show Release_1_0
上記のコマンドは、次の結果を生成します-
tag Release_1_0
Tagger: Tom Cat <[email protected]>
Date: Wed Sep 11 13:45:54 2013 +0530
Tagged basic string operation code
commit 577647211ed44fe2ae479427a0668a4f12ed71a1
Author: Tom Cat <[email protected]>
Date: Wed Sep 11 10:21:20 2013 +0530
Removed executable binary
diff --git a/src/string_operations b/src/string_operations
deleted file mode 100755
index 654004b..0000000
Binary files a/src/string_operations and/dev/null differ
タグを削除
トムは次のコマンドを使用して、ローカルおよびリモートのリポジトリからタグを削除します。
[tom@CentOS project]$ git tag
Release_1_0
[tom@CentOS project]$ git tag -d Release_1_0
Deleted tag 'Release_1_0' (was 0f81ff4)
# Remove tag from remote repository.
[tom@CentOS project]$ git push origin :Release_1_0
To [email protected]:project.git
- [deleted]
Release_1_0