git のタグ付けを試行錯誤。ようやく感じがつかめた。今後はサンプルを作ったらコミット&タグ打ちして、そのタグのついた github の URL を掲載すれば良いことがわかった。
(1) ファイル TEST.1 を追加
$ touch TEST.1 $ git add TEST.1 $ git commit -m "add" [master a890359] add 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 TEST.1 $ git push origin master Counting objects: 3, done. Compressing objects: 100% (2/2), done. Writing objects: 100% (2/2), 233 bytes, done. Total 2 (delta 1), reused 0 (delta 0) To git@github.com:xcatsan/sandbox.git 97ceb55..a890359 master -> master $
結果:
master: TEST.1(2) タグ TAG.1 を追加
$ git tag TAG.1 $ git push origin TAG.1 Total 0 (delta 0), reused 0 (delta 0) To git@github.com:xcatsan/sandbox.git * [new tag] TAG.1 -> TAG.1
結果:
master: TEST.1TAG.1 : TEST.1
(3)ファイル TEST.2 を追加し、TAG.2 を追加
$ touch TEST.2 $ git add TEST.1 $ git commit -m "add" [master 375f883] add2 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 TEST.2 $ git tag TAG.2 $ git push origin master Counting objects: 3, done. Compressing objects: 100% (2/2), done. Writing objects: 100% (2/2), 225 bytes, done. Total 2 (delta 1), reused 0 (delta 0) To git@github.com:xcatsan/sandbox.git a890359..375f883 master -> master $ git push origin TAG.2 Total 0 (delta 0), reused 0 (delta 0) To git@github.com:xcatsan/sandbox.git * [new tag] TAG.2 -> TAG.2
結果:
master: TEST.1, TEST.2
TAG.1 : TEST.1
TAG.2 : TEST.1, TEST.2
(4) ファイル TEST.3 を追加し、TAG.3 を追加
ただし master は push しない
$ touch TEST.3 $ git add TEST.3 $ git commit -m "add3" [master a6aa0b7] add3 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 TEST.3 $ git tag TAG.3 $ git push origin TAG.3 Counting objects: 3, done. Compressing objects: 100% (2/2), done. Writing objects: 100% (2/2), 227 bytes, done. Total 2 (delta 1), reused 0 (delta 0) To git@github.com:xcatsan/sandbox.git * [new tag] TAG.3 -> TAG.3
結果:
master: TEST.1, TEST.2
TAG.1 : TEST.1
TAG.2 : TEST.1, TEST.2
TAG.3 : TEST.1, TEST.2, TAG.3
master を push する
$ git push origin master Total 0 (delta 0), reused 0 (delta 0) To git@github.com:xcatsan/sandbox.git 375f883..a6aa0b7 master -> master
結果:
master: TEST.1, TEST.2, TEST.3TAG.1 : TEST.1
TAG.2 : TEST.1, TEST.2
TAG.3 : TEST.1, TEST.2, TEST.3
(5) ファイル TEST.2 を削除し、TAG.4 を追加
$ rm TEST.2 < $ git rm TEST.2 rm 'TEST.2' $ git commit -m "del" [master 52fa1fb] del 0 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 TEST.2 $ git push origin master Counting objects: 3, done. Compressing objects: 100% (2/2), done. Writing objects: 100% (2/2), 220 bytes, done. Total 2 (delta 1), reused 0 (delta 0) To git@github.com:xcatsan/sandbox.git a6aa0b7..52fa1fb master -> master $ git tag TAG.4 $ git push origin TAG.4 Total 0 (delta 0), reused 0 (delta 0) To git@github.com:xcatsan/sandbox.git * [new tag] TAG.4 -> TAG.4
結果:
master: TEST.1, , TEST.3TAG.1 : TEST.1
TAG.2 : TEST.1, TEST.2
TAG.3 : TEST.1, TEST.2, TEST.3
TAG.4 : TEST.1, , TEST.3
トラブル集
git rm やらずにコミット
# On branch master
# Changed but not updated:
# (use "git add/rm
# (use "git checkout --
#
# deleted: TEST.2
#
no changes added to commit (use "git add" and/or "git commit -a")
タグが無いのにpush
$ git push origin TAG.4
error: src refspec TAG.4 does not match any.
error: failed to push some refs to 'git@github.com:xcatsan/sandbox.git'
Pro Git - Pro Git 2.6 Git の基本 タグ
実例:
xcatsan's sandbox at master - GitHub