git_ws % git clone https://zerobasegit: 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@ github.com/zerobasegit/tag_project.git Cloning into 'tag_project'... remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done.
git_ws % cd tag_project tag_project % cat > hello.txt hello, world. tag_project % git add hello.txt tag_project % git commit -m "commit1" hello.txt [main 20d37a8] commit1 1 file changed, 1 insertion(+) create mode 100644 hello.txt tag_project % cat > hello.txt hello, noma. tag_project % git commit -m "commit2" hello.txt [main 18b2e87] commit2 1 file changed, 1 insertion(+), 1 deletion(-) tag_project % cat > hello.txt hello, zerobase. tag_project % git commit -m "commit3" hello.txt [main 56018a5] commit3 1 file changed, 1 insertion(+), 1 deletion(-)
(commit 1 : hello, world.)
(commit 2 : hello, noma.)
(commit 3 : hello, zerobase.)
tag_project % git push origin main Counting objects: 9, done. Delta compression using up to 8 threads. Compressing objects: 100% (6/6), done. Writing objects: 100% (9/9), 788 bytes | 788.00 KiB/s, done. Total 9 (delta 0), reused 0 (delta 0) To https://github.com/zerobasegit/tag_project.git dfe19e7..56018a5 main -> main
특정 버전 (Commit) 에 Tag 를 달아놓을 필요가 있을 때 사용
(예 - 버전 릴리즈)
Git Tag 생성 1
현재 버전(마지막 버전)에 Tag 달기
git tag <tagname>
tag_project % git tag v0.3
tag_project % git log commit 56018a50e3838378d9ec4004d0197dc3314ad00c (HEAD -> main, tag: v0.3, origin/main , origin/HEAD) Author: zerobasegit <zerobase.git@gmail.com> Date: Sun Nov 7 23:48:22 2021 +0900 commit3 commit 18b2e87cd44fe902566d7cf0a6692e36bae28172 Author: zerobasegit <zerobase.git@gmail.com> Date: Sun Nov 7 23:48:07 2021 +0900 commit2
git tag <tagname> <commithash>
tag_project % git tag v0.2 18b2e87cd44fe902566d7cf0a6692e36bae2817
tag_project % git log commit 56018a50e3838378d9ec4004d0197dc3314ad00c (HEAD -> main, tag: v0.3, origin/main, origin/HEAD) Author: zerobasegit <zerobase.git@gmail.com> Date: Sun Nov 7 23:48:22 2021 +0900 commit3 commit 18b2e87cd44fe902566d7cf0a6692e36bae28172 (tag: v0.2) Author: zerobasegit <zerobase.git@gmail.com> Date: Sun Nov 7 23:48:07 2021 +0900 commit2 commit 20d37a807afa309fc06772073a7e1c5ae79cb95d Author: zerobasegit <zerobase.git@gmail.com> Date: Sun Nov 7 23:47:47 2021 +0900 commit1
(두번째 commit 2 에 (tag: v0.2) 가 생겼다
git push origin <tagname>
tag_project % git push origin v0.3 Total 0 (delta 0), reused 0 (delta 0) To https://github.com/zerobasegit/tag_project.git * [new tag] v0.3 -> v0.3
git tag
tag_project % git tag v0.2 v0.3
git show <tagname>
tag_project % git show v0.2 commit 18b2e87cd44fe902566d7cf0a6692e36bae28172 (tag: v0.2) Author: zerobasegit <zerobase.git@gmail.com> Date: Sun Nov 7 23:48:07 2021 +0900 commit2 diff --git a/hello.txt b/hello.txt index af81e4b..a13488d 100644 --- a/hello.txt +++ b/hello.txt @@ -1 +1 @@ -hello, world. +hello, noma.
git tag --delete <tagname>
tag_project % git tag --delete v0.3 Deleted tag 'v0.3' (was 56018a5) tag_project % git tag v0.2
git push --delete origin <tagname>
tag_project % git push --delete origin v0.3 To https://github.com/zerobasegit/tag_project.git - [deleted] v0.3
위 글은 제로베이스 데이터 취업 스쿨의 강의자료를 참고하여 작성되었습니다.