Git 05. Remote Repository

Jasmine·2023년 6월 6일
0

Git

목록 보기
3/7

Remote Repository 생성

Default Branch

  • 디폴트 설정
    Git : Master
    Github : Main
  • 수정 가능. 다른 팀원들까지 영향을 받는다.
  • Remote Repository 를 생성할 때 Default Branch 이름을 설정할 수 있음 (Settings > Repositories)

Remote Repository 복제하기 (Git Clone)

  • Local Repository 를 생성하지 않은 상태에서
    Git Clone 명령을 사용하여 Remote Repository 를 Local 에 복제할 수 있음

Git Clone

앞서 폴더를 만들고 + Git Init 으로 해당 폴더를 초기화 하고 + Remote Repository 를 등록하고 + Remote Repository 의 내용을 Pull 하는 모든 과정을 Git Clone 으로 할수 있음

git clone https://github.com/<repository>.git

# Git Clone with username and token
git clone https://<username>:<token>@github.com/<repository>.git

생성확인
ls -all
cat README.md

Branch

Branch 조회

Local Branch 조회

git branch

Remote Branch 조회

git branch -r

(Local + Remote) Branch 조회

git branch -a

Branch 생성&이동

Branch 생성

git branch <branchname>

Branch 이동

git checkout <branchname>

Branch 생성 + 이동

git checkout -b <branchname>
  • Local Repository 에 생성된 Branch 는 Remote Repository (GitHub) 에서 보이지않음

Branch 생성 (Remote Repository)

git push origin <branchname>

Branch 삭제

Branch 삭제 (Local Repository)

git branch -d <branchname>

# 확인
git branch -a

Branch 삭제 (Remote Repository)

git push origin --delete <branchname>

혼자 해봅시다

  1. Remote Repository 생성하기
    • 이름 : branch_project
    • Option : README.md, .gitignore (Python)

  2. Local 에 Clone
    • 위치 : git_ws 하위
    • 생성 확인

  3. Branch 생성 후 이동
    • 이름 : branch01, branch02
    • 이동 : branch01
    • 확인 : Local Branch 목록 (현재 Branch 위치 - branch01)

  4. Branch Push
    • Push : branch01, branch02
    • 확인 : Remote Branch 목록, GitHub

  5. Local Branch 삭제
    • Local Branch 삭제 : branch01
    • 확인 : Local Branch 목록 (에러상황 처리 포함)

  6. 남은 Local Branch 모두 삭제
    • main branch 제외
    • 확인 : 전체 Branch 목록

  7. Remote Branch 모두 삭제
    • main, HEAD 제외
    • 확인 : 전체 Branch 목록 , GitHub

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

0개의 댓글

관련 채용 정보