Git - Tag

jaam._.mini·2024년 1월 3일
0

💻 GIT

목록 보기
4/5
post-thumbnail

Commit들 사이에서 tag해서 바로 찾아갈 수 있는 기능

실습 환경


  1. Local Repository 복사
    git_ws 폴더 하위

    PC@DESKTOP-7USISEH MINGW64 ~
    $ cd Documents/
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents (master)
    $ cd git_ws/
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws (master)
    $ git clone https://JaeminOh94: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@github.com/JaeminOh94/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
    Receiving objects: 100% (3/3), done.
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws (master)
    $ cd tag_project/
  2. 파일 생성 후 commit 3개 만들기
    • 파일 이름 : hello.txt
    • commit 1 : Hello, world.

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
    $ cat > hello.txt
    hello, world
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
    $ cat hello.txt
    hello, world
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
    $ git add hello.txt
    warning: in the working copy of 'hello.txt', LF will be replaced by CRLF the next time Git touches it
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
    $ git commit -m 'commit 1' hello.txt
    warning: in the working copy of 'hello.txt', LF will be replaced by CRLF the next time Git touches it
    [main 605daef] commit 1
     1 file changed, 1 insertion(+)
     create mode 100644 hello.txt

• commit 2 : Hello, noma.

PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
$ cat > hello.txt
Hello, noma

PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
$ git add hello.txt

PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
$ git commit -m 'commit 2' hello.txt
main 6d3b149] commit 2
1 file changed, 1 insertion(+), 1 deletion(-)

• commit 3 : Hello, zerobase.

  PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
  $ cat > hello.txt
  Hello, zerobase

  PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
  $ git add hello.txt
  warning: in the working copy of 'hello.txt', LF will be replaced by CRLF the next time Git touches it

  PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
  $ git commit -m 'commit 3' hello.txt
  warning: in the working copy of 'hello.txt', LF will be replaced by CRLF the next time Git touches it
  [main 7ee36a5] commit 3
   1 file changed, 1 insertion(+), 1 deletion(-)
  1. Remote Repository 에 Push

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
    $ git push origin main

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
    $ git log
    commit 7ee36a5af7682fe853ffe371401d0de6110fb64a (HEAD -> main, origin/main, origin/HEAD)
    Author: JaeminOh94 <94woals@naver.com>
    Date:   Wed Jan 3 13:42:29 2024 +0900
    
        commit 3
    
    commit 6d3b14927a89a3774fa9b115d8c8e67d596c8f7d
    Author: JaeminOh94 <94woals@naver.com>
    Date:   Wed Jan 3 13:41:42 2024 +0900
    
        commit 2
    
    commit 605daef5f1caefe9381cd594f8a63c3dd92bc418
    Author: JaeminOh94 <94woals@naver.com>
    Date:   Wed Jan 3 13:39:55 2024 +0900
    
        commit 1
    
    commit 0b0bfab2dee78695ef6f1cfe6d86c5eefd521b33
    Author: JaeminOh94 <155232890+JaeminOh94@users.noreply.github.com>
    Date:   Wed Jan 3 13:36:50 2024 +0900
    
    :

Tag


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

  1. Git Tag 생성 1
  • 현재 버전에 Tag 달기
    git tag <tagname>

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

    • 📌 git log >> commit 3 >> tag: v0.3 생김.

      PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
      $ git tag v0.3
      
      PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
      $ git log
      commit 7ee36a5af7682fe853ffe371401d0de6110fb64a (HEAD -> main, 📌tag: v0.3, origin/main, origin/HEAD)
      Author: JaeminOh94 <94woals@naver.com>
      Date:   Wed Jan 3 13:42:29 2024 +0900
      
          commit 3
  1. Git Tag 생성 2
  • 특정 버전에 Tag 달기
    git tag <tagname> <commithash>
  • 특정 버전 (Commit2) 에 Tag (v0.2) 달기
  • Tag 확인
  1. Git Tag 생성 3
  • Tag 를 Remote Repository 에 Push
    git push origin <tagname>

  • Tag 를 Remote Repository 에 Push

  • Tag 확인

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
    $ git push origin v0.3
    Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
    To https://github.com/JaeminOh94/tag_project.git
     * [new tag]         v0.3 -> v0.3
    

  1. Git Tag 목록 보기
    git tag

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
    $ git tag
    v0.2
    v0.3
  2. Git Tag 상세 정보
    git show <tagname>

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
    $ git show v0.3
    commit 7ee36a5af7682fe853ffe371401d0de6110fb64a (HEAD -> main, tag: v0.3, origin/main, origin/HEAD)
    Author: JaeminOh94 <94woals@naver.com>
    Date:   Wed Jan 3 13:42:29 2024 +0900
    
        commit 3
    
    diff --git a/hello.txt b/hello.txt
    index 3ef669d..e4e6377 100644
    --- a/hello.txt
    +++ b/hello.txt
    @@ -1 +1 @@
    -^VHello, noma
    +Hello, zerobase
  3. Git Tag 삭제
    git tag --delete <tagname>
    git push --delete origin <tagname>

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
    $ git tag --delete v0.3
    Deleted tag 'v0.3' (was 7ee36a5)
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
    $ git tag
    v0.2
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/tag_project (main)
    $ git push --delete origin v0.3
    To https://github.com/JaeminOh94/tag_project.git
     - [deleted]         v0.3

profile
비전공자의 데이터 공부법

0개의 댓글