💻/Git

Git9 (Git Tag)

PangLog 2022. 1. 5. 15:28

중요한 버전은 바로 찾아가자구 !


  • Tag : 무수히 많은 commit중 중요한 commit에 태깅을 해서 바로 찾아갈 수 있도록 하는 기능
  • 즉, 특정 버전(Commit)에 Tag를 달아놓을 필요가 있을 때 사용(ex- 버전 릴리즈)

실습환경 구축

  • Remote Repository(이번 이름은 tag_project)만들고 clone!
  • 총 3 번 commit 하기
cat > hello.txt
hello, kim

git add hello.txt
git commit -m 'commit1' hello.txt

cat > hello.txt
hello, lee
git commit -m 'commit2' hello.txt

cat > hello.txt
hello, park
git commit -m 'commit3' hello.txt

Tag

  • Git Tag 생성 1
    • 현재 버전(마지막 버전)에 태그 달기
git tag <tagname>
# 현재버전(Commit3)에 Tag(v0.3) 달기
# ex) git tag v0.3

# 확인
git log

  • Git Tag 생성 2
    • 특정 버전에 Tag 달기
git tag <tagname> <commithash>
# ex) git tag v0.2  499a9a0eafc40fe369ceec1fe306c1d8729d89bb

git log

  • Git Tag 생성 3
    • Tag를 Remote Repository에 push
git push origin <tagname>

  • Remote repository에 태그를 push한게 뜸

  • 여태까지 단 Tag들의 목록 조회
git tag
  • Git Tag 상세 정보
git show <tagname>

  • Git Tag 삭제 1
git tag --delete <tagname>
  • Git Tag 삭제 2(Remote Repository에서만 삭제)
git push --delete origin <tagname>
반응형