Git 09. Tag

Jasmine·2023년 6월 10일
0

Git

목록 보기
6/7

실습환경 만들기

Remote Repository 생성

• tag_project

Remote Repository 주소 복사

Local Repository 복사

• git_ws 폴더 하위

$ git clone https://grownje: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@github.com/grownje/tag_project.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.

$ git add hello.txt

$ git commit -m 'commit 1' hello.txt

$cat > hello.txt
hello, noma. 

$ git commit -m "commit2" hello.txt

$ cat > hello.txt
hello, zerobase.

$ git commit -m "commit3" hello.txt

Remote Repository 에 Push

$ git push origin main

Tag

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

Git Tag 생성 1

현재 버전에 Tag 달기

git tag <tagname>

Git Tag 생성 1 실습
현재 버전 (Commit3) 에 Tag (v0.3) 달기

tag_project % git tag v0.3

Git Tag 생성 2

특정 버전에 Tag 달기

git tag <tagname> <commithash>

Git Tag 생성 2 실습
특정 버전 (Commit2) 에 Tag (v0.2) 달기

tag_project % git tag v0.2 18b2e87cd44fe902566d7cf0a6692e36bae2817

Tag 확인

tag_project % git log

Git Tag 생성 3 (remote)

Tag 를 Remote Repository 에 Push

git push origin <tagname>

Git Tag 생성 3 실습
Tag 를 Remote Repository 에 Push

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 목록 보기

git tag

Git Tag 상세 정보

git show <tagname>

Git Tag 삭제 1 (local)

git tag --delete <tagname>

Git Tag 삭제 1 실습

tag_project % git tag --delete v0.3
Deleted tag 'v0.3' (was 56018a5)

tag_project % git tag
v0.2

Git Tag 삭제 2 (remote)

git push --delete origin <tagname>

Git Tag 삭제 2 실습

tag_project % git push --delete origin v0.3
To https://github.com/zerobasegit/tag_project.git
 - [deleted] v0.3

따라해봅시다

  1. tag_project 의 모든 tag 삭제
$ git tag
v0.2

$ git tag --delete v0.2
  1. tag_project 에 tag 달고 tag 목록 및 상세정보 확인
    • commit1 : v0.1
    • commit2 : v0.2
    • commit3 : v0.3
git log -> commit hash code 확인하고
git tag v0.1 <commithash>
git log -> 태그 달린거 확인
git tag v0.2 <commithash>
git tag v0.3 -> 마지막이니까 hash code 안써도 됨

git tag -> 목록 확인
git show v0.1
git show v0.2
git show v0.3
  1. Git Tag 전부 Remote Repository 에 Push 하고 확인
git push origin v0.1
git push origin v0.2
git push origin v0.3
  1. V0.1 Tag Local + Remote 에서 지우고 확인
git tag --delete v0.1

git tag 	# 삭제확인

git push --delete origin v0.1
  1. V0.2 Tag Local + Remote 에서 지우고 확인

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

profile
데이터직무를 위한 공부 기록

0개의 댓글

관련 채용 정보