git(6) - Fork๐ด & pull request๐
2022, Jul 07
๋ชฉ์
A๋ฟ๋ง ์๋๋ผ B๋ ๋ก์ปฌ ์ ์ฅ์์ ๋ธ๋์น๋ฅผ ์์ฑํด์ ๊ฐ์ ์๊ฒฉ ์ ์ฅ์์ ํธ์ํ๋ ๊ฒฝ์ฐ์ ์ถฉ๋์ด ์ผ์ด๋ ์ ์๊ธฐ๋๋ฌธ์ pull request๋ฅผ ํตํด ์๊ฒฉ ์ ์ฅ์์ ์์ฒญํ๊ณ ์๊ฒฉ ์ ์ฅ์์์ merge ํ๋๊ฒ
๋ํ ์์ ์ด ์์ ํ์ง ์๊ณ ๊ถํ์ด ์๋ ์์ ์ ๋ํด ํ์ ํ๊ธฐ ์ํด์ ์ฌ์ฉํ๋ค.
์ฌ์ฉ ๋ฐฉ๋ฒ
1. Fork
- ๊ฐ์ ธ์ค๊ณ ์ ํ๋ ์ ์ฅ์๋ฅผ ์์ ์ ์ ์ฅ์๋ก Forkํ๋ค.

2. ๋ด ์ปดํจํฐ์ ๋ก์ปฌ์ ์ฅ์์ ์๊ฒฉ์ ์ฅ์๋ฅผ ์ถ๊ฐ(clone)
- Fork๋ก ์์ฑํ ์ ์ฅ์์์
clone or download๋ฒํผ์ ๋๋ฅด๊ณ ํ์๋๋ URL์ ๋ณต์ฌํ๋ค.
$ git clone {๋ณต์ฌํ URL}
/Users/mac - (main) > cd Desktop # Desktop์ผ๋ก ์ด๋ ํ ํด๋ ์์ฑ
$ git clone https://github.com/kimbap918/pull_folder.git

mac/Desktop - (main) > cd pull_folder # ํด๋ ์์ฑ ํ ์์ฑ๋ ํด๋ ๋ด๋ก ์ด๋
Desktop/pull_folder - (master) >
3. branch ์์ฑ
- ๋ด ์ปดํจํฐ์ clone๋ ์ ์ฅ์(origin)์์ ์ฝ๋๋ฅผ ์์ ํ๊ฑฐ๋ ์ถ๊ฐํ๋ ์์ ์ branch๋ฅผ ๋ง๋ค์ด์ ์งํํ๋ค.
$ git branch {branch name}
$ git branch example
Desktop/pull_folder - (master) > git branch example
- ์์ฑ ํ ์ด๋
$ git checkout {branch name}
$ git checkout example
Desktop/pull_folder - (master) > git checkout example
Switched to branch 'example'
Desktop/pull_folder - (example) > # master -> example๋ก branch๊ฐ ์ด๋๋จ
- ์์ฑ๋ ํด๋์ ๋ชจ์ต

4. ์์ ์์ ํ add, commit, push
- ์์ ๋ฌผ์ ์ถ๊ฐ

Desktop/pull_folder - (example) > git add .
Desktop/pull_folder - (example) > git commit -m "request"
Desktop/pull_folder - (example) > git push origin example
- ์์ ์ด ์๋ฃ๋๋ฉด Github Repository(origin)์ add, commit, pushํ๋ค.
- pushํ ๋ develop ๋ธ๋์น์ ์์ ๋ด์ญ์ origin์ผ๋ก ํธ์ํ๋ค.
5. pull Request ์์ฑ
- push ์๋ฃํ ์์ ์ github ์ ์ฅ์์์
Compare & pull request๋ฒํผ์ด ํ์ฑํ ๋์ด์๋๊ฑธ ํ์ธํ ์ ์๋ค. - ๋ฒํผ์ ์ ํํด Pull Request๋ฅผ ์์ฑํ๋ค.

- ๋ด์ฉ์ ์์ฑ ํ pull request ๋ฅผ ์์ฑ

6. Merge Pull Request
- PR์ ๋ฐ์ ๊ด๋ฆฌ์๋ ์ฝ๋ ๋ณ๊ฒฝ๋ด์ญ์ ํ์ธํ๊ณ Merge์ฌ๋ถ๋ฅผ ๊ฒฐ์ ํ๊ฒ ๋๋ค.
7. Merge ์ดํ ๋๊ธฐํ ๋ฐ branch ์ญ์
- Merge๊ฐ ์๋ฃ๋๋ฉด ๋ก์ปฌ ์ฝ๋์ ์๋ณธ์ ์ฝ๋๋ฅผ ๋ณํฉํ๊ณ ์ต์ ์ ์ํ๋ฅผ ์ ์งํ๊ฒ ์ํด ๋๊ธฐํํ๋ค.
- upstream ํ์ธ
$ git remote -v
- upstream ์ถ๊ฐ
$ git remote add upstream
$ git fetch upstream
$ git merge upstream/master
$ git branch -d example
- ์ ๋ช ๋ น์ด๋ฅผ ํตํด ๋๊ธฐํํ๊ณ , ๋ธ๋์น๋ฅผ ์ญ์ ํ๋ค.