[제로베이스 데이터 취업 스쿨] 9기 12주차 - Git (8): Tag

Inhee Kim·2023년 1월 15일
0
post-thumbnail

Tag

1. 실습 환경 만들기

Remote Repository 생성

Local Repository 복사

  • git_ws 폴더 하위
cd Documents/git_ws

git clone https://<username>:<token>@github.com/<repository>.git

파일 생성 후 commit 3개 만들기

  • 파일 이름 : hello.txt
  • commit 1 : Hello, world.
  • commit 2 : Hello, noma.
  • commit 3 : Hello, zerobase.
cd tag_project

cat > hello.txt
Hello, world. + ctrl + D

git add hello.txt
git commit -m "commit 1" hello.txt

cat > hello.txt
Hello, noma. + ctrl + D

git add hello.txt
git commit -m "commit 2" hello.txt

cat > hello.txt
Hello, zerobase. + ctrl + D

git add hello.txt
git commit -m "commit 3" hello.txt

Remote Repository에 Push

git push origin main

git log

2. Tag

  • 특정 버전(Commit)에 Tag를 달아놓을 필요가 있을 때 사용 (예 - 버전 릴리즈)

(1) Git Tag 생성 1
문법

  • 현재 버전에 Tag 달기
git tag <tagname>

실습

  • 현재 버전(Commit3)에 Tag(v0.3) 달기
git tag v0.3

  • Tag 확인
git log

(2) Git Tag 생성 2
문법

  • 특정 버전에 Tag 달기
git tag <tagname> <commithash>

실습

  • 특정 버전(Commit2)에 Tag(v0.2) 달기
git tag v0.2 23097d071832a529c631140cf36d8693d356b6db

  • Tag 확인
git log

(3) Git Tag 생성 3
문법

  • Tag를 Remote Repository에 Push
git push origin <tagname>

실습

  • Tag를 Remote Repository에 Push
git push origin v0.3

  • Tag 정보 확인

(4) *Git Tag 목록 보기
문법

git tag

실습

git tag

(5) Git Tag 상세 정보
문법

git show <tagname> 

실습

git show v0.2

(6) Git Tag 삭제 1
문법

git tag --delete <tagname>

실습

git tag --delete v0.3
git tag

(7) Git Tag 삭제 2
문법

git push --delete origin <tagname> 

실습

git push --delete origin v0.3

문제풀이

1. tag_project의 모든 tag 삭제

git tag
git tag --delete v0.2
git tag

2. tag_project에 tag 달고 tag 목록 및 상세정보 확인

  • commit1 : v0.1
  • commit2 : v0.2
  • commit3 : v0.3
git log

git tag v0.1 6a6f5249506ba4423a2543f9b4756a5c9f65f2b2
git tag v0.2 23097d071832a529c631140cf36d8693d356b6db
git tag v0.3

git log

git tag
git show v0.1
git show v0.2
git show v0.3

3. Git Tag 전부 Remote Repository에 Push하고 확인

git push origin v0.1
git push origin v0.2
git push origin v0.3

4. V0.1 Tag Local + Remote에서 지우고 확인

git tag --delete v0.1
git tag
git push --delete origin v0.1

5. V0.2 Tag Local + Remote에서 지우고 확인

git tag --delete v0.2
git tag
git push --delete origin v0.2

6. V0.3 Tag Local + Remote에서 지우고 확인

git tag --delete v0.3
git tag
git push --delete origin v0.3

profile
Date Scientist & Data Analyst

0개의 댓글