/
github PR(pull request) 을 merge 하지 않고 local 로 받기
github PR(pull request) 을 merge 하지 않고 local 로 받기
PR 만 받기
github Pull Request 요청이 왔을 때 바로 Merge pull request 를 하지 않고 local 환경에서 검증해 보고 싶은 경우가 있습니다.
gist에 이 내용을 잘 설명한 문서가 있는데 github markdown 이라서 보기 편하게 정리해 봅니다.
아래 예제는 github 프로젝트 URL 이 git@github.com:YOUR_ACCOUNT/PROJECT.git 이므로 실제 URL 로 변경해야 됩니다.
프로젝트 폴더내의 .git/config 파일을 편집기로 오픈합니다.
remote "origin" 부분을 찾습니다.
[remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = git@github.com:YOUR_ACCOUNT/PROJECT.git
url 밑에 다음과 같이 fetch 항목을 추가합니다.
url = git@github.com:YOUR_ACCOUNT/PROJECT.git fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
repository 에서 fetch 를 받습니다.
$ git fetch origin * [new ref] refs/pull/158/head -> origin/pr/158 * [new ref] refs/pull/157/head -> origin/pr/157
검증할 PR 번호(예: 158) 을 선택해서 체크아웃 합니다.
$ git checkout origin/pr/158
아래 명령어를 실행하면 1 ~ 3번 과정을 더 쉽게 할 수 있습니다.
git config --add remote.origin.fetch +refs/pull/*/head:refs/remotes/origin/pr/*
upstream PR 받기
fork 한 프로젝트에서 upstream 의 PR 을 가져오려면 다음 명령어를 실행합니다.
upstream 저장소의 이름이 upstream 이어야 합니다.
git config --add remote.upstream.fetch +refs/pull/*/head:refs/remotes/upstream/pr/*
upstream 저장소에서 PR 을 가져옵니다.
git fetch upstream
업스트림에 있는 PR 번호로 체크아웃 받습니다.
git checkout upstream/pr/1490
Ref
- https://help.github.com/articles/checking-out-pull-requests-locally/
- https://bocoup.com/weblog/git-workflow-walkthrough-reviewing-pull-requests-local
, multiple selections available,
Related content
git fetch vs pull
git fetch vs pull
More like this
git push/pull 할때 fatal: refusing to merge unrelated histories 문제 해결
git push/pull 할때 fatal: refusing to merge unrelated histories 문제 해결
More like this
git bare repository 설정 및 다른 프로토콜(HTTP, SSH) 과 연계
git bare repository 설정 및 다른 프로토콜(HTTP, SSH) 과 연계
More like this
gitlab 프로젝트 리셋하기
gitlab 프로젝트 리셋하기
More like this
git 버전 관리 무시 목록(ignore) 설정법(.gitignore)
git 버전 관리 무시 목록(ignore) 설정법(.gitignore)
More like this
github 에서 push나 PR(pull request) 할때 issue 연결하기
github 에서 push나 PR(pull request) 할때 issue 연결하기
More like this