본문으로 바로가기

[git] Pull Request

category ETC 2021. 11. 3. 18:23
728x90

Pull Request를 사용하게 된 이유

1. 코드리뷰

2. 다른사람과 협업하기 위해

3. 바로 머지 되지 않으므로 코드에 좀 더 신경 쓸 수 있음

Pull Request를 보내기 위한 방법

1. base repo를 fork

2. base repo를 clone

3. .git/config 수정 

vi .git/config

[remote "upstream"]

        url = base repo

        fetch = +refs/heads/*:refs/remotes/upstream/*

[remote "origin"]

        url = fork repo

        fetch = +refs/heads/*:refs/remotes/origin/*
git remote -v
    origin	forkrepo (fetch)
    origin	forkrepo (push)
    upstream	baserepo (fetch)
    upstream	baserepo (push)

4. Pull Request를 보내기 위한 작업 방식

#base repo의 특정 branch를 받음
git fetch upstream test2021

#받은 특정 branch를 test1의 로컬 브랜치로 설정하고 해당 로컬 브랜치로 checkout
git checkout upstream/test2021 -b test1

파일 수정

#commit에 올릴 파일 or 디렉토리 경로
git add 파일이름

#git add -A (작업 디렉토리 내 모든 변경사항 add)
#git add . (현재 디렉토리 내 모든 변경사항 add)


#commit에 넣을 메세지
git commit -m “커밋메세지"

#로컬의 test1 브랜치를 fork repo에 push
git push origin test1