깃허브 github 초기설정 _ Mac

김상윤·2022년 1월 19일
0

github

목록 보기
1/1

Working Directory (Local Repository)

  1. 터미널에서 원하는 디렉토리(폴더)로 이동
cd dir
  1. 사용자, 계정 설정
    : username은 되도록 github 이름과 통일시키기
git config --global user.name "YourName"
git config --global user.email "your_email@youremail.com"
  1. 해당 디렉토리를 git으로 관리할 수 있도록, git 초기화 진행
git init
  • remote repository 로컬로 복사해오기
git clone 원격 저장소 주소

Stagin Area

  1. Staging Area에 작업 끝난 파일 추가
git add file.py 	//file.py파일 추가
git add . 	//working directory의 모든 (Untracked)파일 추가
  • Stagin Area 상태 확인
git status

Repository

  • Stagin Area의 데이터를 확정하여 로컬 저장소(repository)에 올리기
git commit -m "commit message"
  • 커밋 내역 확인
git log
  • 좋은 commit message
    • 제목과본문을한줄띄워분리하기 • 제목은영문기준50자이내로
    • 제목첫글자를대문자로
    • 제목끝에.금지
    • 제목은명령조로
    • 본문은영문기준72자마다줄바꾸기
    • 본문은어떻게보다무엇을,왜에맞춰작성하기

Remote Repository (깃허브)

  • 연결된 Remote Repository 확인
git remote -v
  • Remote Repository 연결하기
git remote add [Remote명] [깃허브 주소]
git remote add origin https://github.com/tkddbs0411/tkddbs0411.github.io.git
  • Remote Repository에 commit한 데이터 push
git push [Remote명] [Branch명]
git push origin master
  • pull ( fetch + merge )
    : Remote Repository에서 최신 커밋 내역을 가져와서, Local Repository에 합친다.
git pull [Remote명] [Branch명]
git pull origin master
  • fork 후 연결 시 기존 Remote Repository는 연결 되지 않아서 해당 repository의 최신 commit 내역 조회 불가능
    -> 추가로 연결하여 최신 commit pull 해올 수 있다.
git remote add parent 부모Repository주소
git fetch parent
//git fetch [Remote명]
git merge parent/master
//git merge [Branch명]

branch 설정

  • branch 생성
git branch [Branch명]
  • working 현재 브랜치 전환
git checkout [Branch명]
  • 해당 브랜치를 현재 브랜치에 합침
git merge [합칠 Branch명]

0개의 댓글