GIT - Local/Remote Repository & 전체 실습

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

💻 GIT

목록 보기
1/5
post-thumbnail

기본 설정


  • Global Username & Email
    git config --global user.name <username>
    git config --global user.email <email>
  • CRLF _ window 사용자의 경우

    • 데이터를 가져올 때 : LF -> CRLF
    • 데이터를 보낼 때 : CRLF -> LF
      git config --global core.autocrlf true
  • Editor

    git config --global core.editor vim
  • 전체 설정 확인

    git config --list
  • 항목별 설정 확인

    git config <key>

기본 용어


  • Repository

    • 소스코드가 저장되어 있는 여러 개의 Branch 가 모여 있는 디스크 상의 물리적 공간
    • Local Repository
    • Remote Repository
  • Check out

    • 특정 시점이나 Branch의 소스코드로 이동하는 것
    • 버전은 Commit을 통해서 계속 버전을 메기고 있고
    • 특정 버전에 tag를 달아서 taging해서 표기 할 수 있음
    • check out을 통해 과거의 여러 시점의 코드로 이동
  • Stage

    • 작업할 내용이 올라가는 임시저장 영역
    • 이 영역을 이용해 작업한 내용 중 commit에 반영할 파일만 선별해 commit이 가능
    • Git이 관리하는 단계가 있는데
      • working directory : 맨 처음 윈도우 폴더에 파일을 모아 놓는 것 (눈에 보임)
      • stage 공간 : 파일 선정, git에서 관리한다고 등록
      • head 영역 : 수정을 해서 버전을 메김
  • Commit

    • 버전을 메기는 행위
    • 내가 작업하는 영역(local repository)에 저장
    • 각각의 commit의 설명은 commit log로 남김 (= 버전에 대한 설명)
    • 권장 : commit을 아끼지 마세요
  • Tag

    • commit을 통해 남긴 것들은 구분되나, 더 과거 데이터는 tag를 붙임
    • 임의의 commit 위치에 쉽게 찾아갈 수 있도록 붙여놓은 이정표
    • Tag가 붙은 commit은 commit id(version) 대신 tag name으로 쉽게 check out 가능
  • Push

    • local repository에서 내용 수정, remote repositiry에 반영하고 싶을 때 push를 함
    • 권장 : push하는 순간 다른 개발자들도 영향을 받음
  • Pull

    • 내가 local에서 작업하지 않았는데, remote는 다른 개발자들이 작업, 변경 내용을 다시 local로 가져와서 싱크를 맞추고 싶을 때 사용
    • 같은 부분이 수정되면 Conflict(충돌)이 일어나서 Push가 거절된 경우 Pull을 이용해 remote의 변경 내용을 local에 반영해 Conflict를 해결한 뒤 다시 push를 시도해야 함
  • Branch

    • 제일 기본 브랜치가 생기고, 버전이 계속 올라가는데, COPY해서 어떤걸 해보고 싶을 때 Branch(병행)이 가능
  • Merge

    • Branch 병합
    • Merge되는 두 Branch는 주종관계가 성립
    • Merge 과정에서 Conflict(충돌)이 발생하는 경우, Diff를 수정해 Conflict를 해결한 뒤 Merge 진행

1. Local Repository


  • Workspace 생성

    mkdir git_ws
    
  • Working Dorectory 생성

    • workspace로 이동한 뒤 working directory 생성
    cd git_ws
    git_ws mkdir test_project
    
  • Git init

    • 폴더에 Git을 초기화하는 명령어를 사용
    • 해당 폴더를 Git이 관리하기 시작
    • git init 하는 순간 이 폴더는 Repository가 됨 (Git이 Working Dorectory로 인식했다는 말)
    git init
  • 파일 생성

    • working directory에 파일 생성
      참고 > touch 명령어 - 빈파일을 생성
    test_project % touch test.txt
    test_project % ls
    test.txt
  • Git Status

    • Git에 존재하는 파일 확인
    git status
  • Git Add

    • Working Directory에서 변경된 파일을 index(stage)에 추가
    • Working Directory → Stage 하고 싶을 때.
     git add <filename>
  • Git Commit

    • index(stage)에 추가된 변경사항을 HEAD에 반영(확정)
    • stage → head 반영 시 version을 메기면 됨(=git dommit)
      git commit -m "commit 에 대한 설명" <filename>

실습


1단계 : Working Directory

  • 파일 생성

    PC@DESKTOP-7USISEH MINGW64 ~
    $ cd Documents/
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents
    $ mkdir git_ws

  • Git init

    • 해당 폴더를 Git이 관리하기 시작
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws
    $ mkdir test_project
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws
    $ cd test_project
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/test_project
    $ git init
    Initialized empty Git repository in C:/Users/PC/Documents/git_ws/test_project/.git/
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/test_project (master) 📌관리하기 시작했다는 뜻
    
  • 결과

    • 숨김파일 확인 (ls -all)
  • text 파일 생성

  • git status

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/test_project (master)
    $ git status
    On branch master
    
    No commits yet
    
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
            test.txt
    
    nothing added to commit but untracked files present (use "git add" to track)
    

2 단계

  • git add
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/test_project (master)
    $ git add test.txt

3 단계

  • Git Commit
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/test_project (master)
    $ git commit -m 'first commit' test.txt
    [master (root-commit) 82b296c] first commit
     1 file changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 test.txt

2. Remote Repository

1. 생성


  • Github Token 생성
    • 얼마전부터 보안상의 이유로 Remote Repository 접속 시 비밀번호 대신 Token을 사용
    • [personal access token] 선택

2. 등록


  • Local Resository에 연동할 Remote Repository를 등록 (Token 사용)

    git remote add origin http://<username>:<token>@github.com/<repository>.git
    • 설명
      • git 명령을 줄건데,
      • remote를 add 할거야
      • origin 이란 이름으로
      • remote repository(http:// )주소를
      • local repository에 연결할거야
    PC@DESKTOP-7USISEH MINGW64 ~
    $ cd Documents/
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents
    $ cd git_ws/
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws
    $ cd test_project/
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/test_project (master)
    $ git remote add origin https://JaeminOh94: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@github.com/JaeminOh94/test_project.git
  • 정보 확인

    • git remote -v
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/test_project (master)
    $ git remote -v
    origin  https://JaeminOh94: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@github.com/JaeminOh94/test_project.git (fetch)
    origin  https://JaeminOh94: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@github.com/JaeminOh94/test_project.git (push)

3. 변경내용 Push 하기


LR(HEAD)에 즉, commit 까지 한 내용(반영된 변경내용)을
Remote Repository 에도 반영하기 위해 Git Push 사용

간단히 말하면,
내가 만든 파일을 업로드 하는(=반영) 명령어

  • Git Push

    • LR에 있는 branchname 를 push 할거야
    git push origin <branchname>
  • 실습

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/test_project (master)
    $ git push origin master
    
    Enumerating objects: 3, done.
    Counting objects: 100% (3/3), done.
    Writing objects: 100% (3/3<), 210 bytes | 210.00 KiB/s, done.
    Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
    To https://github.com/JaeminOh94/test_project.git
     * [new branch]      master -> master
    


4. PULL 하기


RR의 내용에 맞춰 LR을 갱신하려면 Git Pull 사용

간단히 말해,
LR(Github online)에서 작업해서 RR(PC file)로 가져오는 것

  • .md : mark down의 약자, 마크다운 문법을 사용

  • Git Pull

    git pull origin <brnachname>


전체 실습


  1. LR 생성
  • 위치 : git_ws

  • 이름 : exam_project

    PC@DESKTOP-7USISEH MINGW64 ~
    $ cd Documents/git_ws/
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws
    $ mkdir exam_project
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws
    $ cd exam_project/
    
  1. 파일 생성 후 Git으로 관리 시작하기
  • 파일 : exam.txt

  • Index 추가

  • HEAD 등록

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project
    $ touch exam.txt
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project
    $ git init
    Initialized empty Git repository in C:/Users/PC/Documents/git_ws/exam_project/.git/
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git add exam.txt
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git status
    On branch master
    
    No commits yet
    
    Changes to be committed:
      (use "git rm --cached <file>..." to unstage)
            new file:   exam.txt
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git commit -m 'add exam.txt' exam.txt
    [master (root-commit) 44fecca] add exam.txt
     1 file changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 exam.txt
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git status
    On branch master
    nothing to commit, working tree clean
    
  1. Remote Repository 생성
  • 이름 : exam_project
  • 빈 프로젝트

  1. Remote Repository
  • (서로 연결) exam_project의 Local Repository에 앞서 생성한 remote repository 등록 후 확인

  • token은 앞서 생성한 token 사용

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git remote add origin https://JaeminOh94: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@github.com/JaeminOh94/exam_project.git
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git remote -v
    origin  https://JaeminOh94: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@github.com/JaeminOh94/exam_project.git (fetch)
    origin  https://JaeminOh94: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@github.com/JaeminOh94/exam_project.git (push)
  1. LR 변경 내용을 RR에 반영
  • commit 항목을 RR에 반영

  • RR에서 exam.txt 확인

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git push origin master
    Enumerating objects: 3, done.
    Counting objects: 100% (3/3), done.
    Writing objects: 100% (3/3), 213 bytes | 213.00 KiB/s, done.
    Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
    To https://github.com/JaeminOh94/exam_project.git
     * [new branch]      master -> master
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git status
    On branch master
    nothing to commit, working tree clean
    

  1. RR 변경 내용을 LR에 반영
  • exam.txt 파일 수정 : This is git exam
    (참고>파일 수정하는 방법)

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ cat exam.txt
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git pull origin master
    remote: Enumerating objects: 5, done.
    remote: Counting objects: 100% (5/5), done.
    remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
    Unpacking objects: 100% (3/3), 637 bytes | 127.00 KiB/s, done.
    From https://github.com/JaeminOh94/exam_project
     * branch            master     -> FETCH_HEAD
       44fecca..18e125f  master     -> origin/master
    Updating 44fecca..18e125f
    Fast-forward
     exam.txt | 1 +
     1 file changed, 1 insertion(+)
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ cat exam.txt
    This is git exam
    
  1. Commit 만들고 각각 Local, Remote 에 반영
  • Commit 1

    • LR -> exam2.txt 생성 후 RR에 반영, 확인
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ touch exam2.txt
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git status
    On branch master
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
            exam2.txt
    
    nothing added to commit but untracked files present (use "git add" to track)
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git add exam2.txt
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git status
    On branch master
    Changes to be committed:
      (use "git restore --staged <file>..." to unstage)
            new file:   exam2.txt
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git commit -m 'commit 1' exam2.txt
    [master cb67b82] commit 1
     1 file changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 exam2.txt
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git status
    On branch master
    nothing to commit, working tree clean
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git push origin master
    Enumerating objects: 4, done.
    Counting objects: 100% (4/4), done.
    Delta compression using up to 8 threads
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 264 bytes | 264.00 KiB/s, done.
    Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
    To https://github.com/JaeminOh94/exam_project.git
       18e125f..cb67b82  master -> master
    
  • Commit 2

    • RR -> exam2.txt 수정 후 LR에 반영, 확인
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git pull origin master
    remote: Enumerating objects: 5, done.
    remote: Counting objects: 100% (5/5), done.
    remote: Compressing objects: 100% (2/2), done.
    remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
    Unpacking objects: 100% (3/3), 660 bytes | 132.00 KiB/s, done.
    From https://github.com/JaeminOh94/exam_project
     * branch            master     -> FETCH_HEAD
       cb67b82..6a55abe  master     -> origin/master
    Updating cb67b82..6a55abe
    Fast-forward
     exam2.txt | 1 +
     1 file changed, 1 insertion(+)
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ cat exam2.txt
    This is git exam2
  • Commit 3

    • LR -> exam3.txt 생성 후 RR에 반영, 확인
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ cat > exam3.txt
    This is git exam3.
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ cat exam3.txt
    This is git exam3.
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git status
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git add exam3.txt
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git status
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git commit -m 'commit 3' exam3.txt
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git status
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/exam_project (master)
    $ git push origin master
    

3. Remote Repository

누군가가 올려놓은 파일에 접속을 해서 Local로 COPY한 다음에 연동해서 작업하는 연습


  • 실습환경 설정

1. Default Branch : master 설정


Branch 설정 변경

2. Git Clone (RR 복제)


LR을 생성하지 않은 상태에서
Git Clone 명령을 사용해 RR을 Local에 복제 가능

  • Git Clone

    • 앞서 폴더를 만들고
    • Git Lnit 으로 해당 폴더를 초기화
    • Remote Repository 등록
    • Remote Repository 내용을 Pull 하는 모든 과정을 Git Clone할 수 있음
    git clone https://<username>:<token>@github.com/<repository>.git

PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws
$ git clone https://JaeminOh94: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@github.com/JaeminOh94/HelloGit.git
Cloning into 'HelloGit'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (4/4), done.

PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws
$ ls
HelloGit/  exam_project/  test_project/

3. Branch


💡 Local → Remote : git add commit push
💡 Remote → Local : git pull

이론

(ㄱ) Local

  • Local Branch 조회

    git branch
  • Remote Branch 조회

    git branch -r
  • Local + Remote Branch 조회

    git branch -a
  • Branch 생성

    git branch <branch name>
  • Branch 이동

    git checkout <branch name>
  • Branch 생성 + 이동

    git checkout -b <branch name>

(ㄴ) Remote

  • Branch 생성
    git push origin <branch name>

(ㄷ) 삭제

  • Local Repository
    git branch -d <branch name>

실습

💡 Local → Remote : git add commit push
💡 Remote → Local : git pull

(1) 조회

  • Local

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (master)
    $ git branch -r
      origin/HEAD -> origin/master
      origin/master
  • Local + Remote

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (master)
    $ git branch -a
    * master
      remotes/origin/HEAD -> origin/master
      remotes/origin/master
    

(2) 생성

  • Local

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (master)
    $ git branch branch01
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (master)
    $ git branch
      branch01
    * master ←💡여기가 활성화 되어 있음
  • Remote (작업한 것을 알려주는 단계)

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (branch02)
    $ git push origin branch01
    
    Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
    remote:
    remote: Create a pull request for 'branch01' on GitHub by visiting:
    remote:      https://github.com/JaeminOh94/HelloGit/pull/new/branch01
    remote:
    To https://github.com/JaeminOh94/HelloGit.git
     * [new branch]      branch01 -> branch01

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (branch02)
    $ git push origin branch02
    
    Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
    remote:
    remote: Create a pull request for 'branch02' on GitHub by visiting:
    remote:      https://github.com/JaeminOh94/HelloGit/pull/new/branch02
    remote:
    To https://github.com/JaeminOh94/HelloGit.git
     * [new branch]      branch02 -> branch02
    

(3) 이동

  • Local

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (master)
    $ git checkout branch01
    Switched to branch 'branch01'
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (branch01) ←💡바뀜
    $ git branch
    * branch01 ←💡여기가 활성화 되어 있음
      master

(4) 생성 + 이동

  • Local
    • git checkout -b branch02
      ⭐ [ -b ] : 있으면 이동, 없으면 생성 후 이동
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (branch01)
    $ git checkout -b branch02
    Switched to a new branch 'branch02'

(5) 삭제

  • Local

    • 삭제 전, master로 이동
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (branch02)
    $ git checkout master
    • [ -d ] : 삭제
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (master)
    $ git branch
      branch01
      branch02
    * master
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (master)
    $ git branch -d branch02
    Deleted branch branch02 (was de9a397).
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (master)
    $ git branch
      branch01
    * master
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (master)
    $ git branch -d branch01
    Deleted branch branch01 (was de9a397).
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (master)
    $ git branch
    * master
    • [ -a ] : 데이터 확인
    • 아직 remote에 전달하지 않아, 데이터가 살아 있음
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (master)
    $ git branch -a
    * master
      remotes/origin/HEAD -> origin/master
      remotes/origin/branch01
      remotes/origin/branch02
      remotes/origin/master
  • Remote

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (master)
    $ git push origin --delete branch02
    To https://github.com/JaeminOh94/HelloGit.git
     - [deleted]         branch02
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (master)
    $ git push origin --delete branch01
    To https://github.com/JaeminOh94/HelloGit.git
     - [deleted]         branch01
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (master)
    $ git branch -a
    * master
      remotes/origin/HEAD -> origin/master
      remotes/origin/master
    

전체 실습


  1. Remote Repository 생성
  • 이름 : branch_project
  • Option : README.md , .gitignore(Python)
  1. Local에 Clone
  • 위치 : git_ws

  • 생성 확인

    📌상위 폴더로 이동
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/HelloGit (master)
    $ cd ..
    
    📌Clone 작업
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws
    $ git clone https://JaeminOh94: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@github.com/JaeminOh94/branch_project.git
    Cloning into 'branch_project'...
    remote: Enumerating objects: 4, done.
    remote: Counting objects: 100% (4/4), done.
    remote: Compressing objects: 100% (3/3), done.
    remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
    Receiving objects: 100% (4/4), done.
    
    📌branch_project 연결
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws
    $ cd branch_project/
    
    📌생성 확인
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/branch_project (main)
    $ ls -all
    
    total 13
    drwxr-xr-x 1 PC 197121    0 Jan  2 02:05 ./
    drwxr-xr-x 1 PC 197121    0 Jan  2 02:05 ../
    drwxr-xr-x 1 PC 197121    0 Jan  2 02:05 .git/
    -rw-r--r-- 1 PC 197121 3238 Jan  2 02:05 .gitignore
    -rw-r--r-- 1 PC 197121   16 Jan  2 02:05 README.md
    
  1. Branch 생성 후 이동
  • 이름 : branch01, branch02

  • 이동 : branch01

  • 확인 : Local Branch 목록 (현재 Branch 위치-branch01)

      📌 생성
      PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/branch_project (main)
      $ git branch branch01
    
      PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/branch_project (main)
      $ git checkout -d branch02
      fatal: git checkout: --detach does not take a path argument 'branch02'
      
     📌 이동
      PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/branch_project (main)
      $ git checkout branch01
      Switched to branch 'branch01'
      
      📌 확인
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/branch_project (branch01)
      $ git branch 
      *  branch01
      branch02
      main
  1. Branch Push
  • Push : branch01, brnach02

  • 확인 : Remote Branch 목록, Github

    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/branch_project (branch02)
    $ git push origin branch01
    Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
    remote:
    remote: Create a pull request for 'branch01' on GitHub by visiting:
    remote:      https://github.com/JaeminOh94/branch_project/pull/new/branch01
    remote:
    To https://github.com/JaeminOh94/branch_project.git
     * [new branch]      branch01 -> branch01
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/branch_project (branch02)
    $ git push origin branch02
    Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
    remote:
    remote: Create a pull request for 'branch02' on GitHub by visiting:
    remote:      https://github.com/JaeminOh94/branch_project/pull/new/branch02
    remote:
    To https://github.com/JaeminOh94/branch_project.git
     * [new branch]      branch02 -> branch02
    
    PC@DESKTOP-7USISEH MINGW64 ~/Documents/git_ws/branch_project (branch02)
    $ git branch
      branch01
    * branch02
      main

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

0개의 댓글