ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [Github] Github์œผ๋กœ ํ˜‘์—…ํ•˜๊ธฐ - Organization(Forking Workflow)
    ๐Ÿ’ปProgramming/Github 2023. 9. 12. 18:09

    ๐Ÿ”— Git๊ณผ Github์˜ ์ฐจ์ด

    Git: ๊ฐœ์ธ ์ปดํ“จํ„ฐ์—์„œ ๋Œ์•„๊ฐ€๋Š” Version Control System - ์ธํ„ฐ๋„ท ์—ฐ๊ฒฐ ์—†์ด๋„ ์‚ฌ์šฉ ๊ฐ€๋Šฅ

    Github: ์„œ๋ฒ„์— ์˜ฌ๋ผ๊ฐ„ Git - ์ธํ„ฐ๋„ท ์—ฐ๊ฒฐํ•ด์•ผ๋งŒ ์‚ฌ์šฉ ๊ฐ€๋Šฅ

    ๐Ÿ”— ์ €์žฅ์†Œ ๋ถ„๋ฅ˜

    ์ค‘์•™ ์›๊ฒฉ(remote) ์ €์žฅ์†Œ: ์—ฌ๋Ÿฌ ๋ช…์ด ํ”„๋กœ์ ํŠธ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋˜๋Š” ๊ทธ๋ฃน ๊ณ„์ •์˜ ์ค‘๋ฆฝ๋œ ์›๊ฒฉ ์ €์žฅ์†Œ

    ์ž์‹ ์˜ ์›๊ฒฉ(remote) ์ €์žฅ์†Œ: Github ์ „์šฉ ์„œ๋ฒ„์—์„œ ๊ด€๋ฆฌ๋˜๋Š” ์›๊ฒฉ ์ €์žฅ์†Œ. 

    ๋กœ์ปฌ(local) ์ €์žฅ์†Œ: ๋‚ด pc์— ์ €์žฅ๋˜๋Š” ์ €์žฅ์†Œ.


    ๐Ÿ”— 1. Fork: ์ค‘์•™ ์›๊ฒฉ ์ €์žฅ์†Œ -> ๋‚ด ์›๊ฒฉ ์ €์žฅ์†Œ

    Organizatioin์—์„œ Repository๋ฅผ ์ƒ์„ฑํ•˜๋ฉด ์ค‘์•™ ์›๊ฒฉ ์ €์žฅ์†Œ๊ฐ€ ์ƒ์„ฑ๋œ๋‹ค. Fork๋ฅผ ํ†ตํ•ด ์ค‘์•™ ์›๊ฒฉ ์ €์žฅ์†Œ์˜ ๋ฆฌํฌ๋ฅผ ๋‚ด ์›๊ฒฉ ์ €์žฅ์†Œ์— ์˜ฎ๊ธฐ๋Š” ๊ฒƒ์ด๋‹ค. (Organization์ด ์•„๋‹ˆ๋ผ ๊ฐœ์ธ์ด ์ƒ์„ฑํ•œ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋„ ๋‚ด ์›๊ฒฉ ์ €์žฅ์†Œ๋กœ Fork ๊ฐ€๋Šฅํ•˜๋‹ค.)

     

     

    ์ค‘์•™ ์›๊ฒฉ ์ €์žฅ์†Œ์˜ ๋ฆฌํฌ์— ๋“ค์–ด๊ฐ€ Fork๋ฅผ ํด๋ฆญํ•˜๋ฉด

     

    ์ด๋Ÿฐ ์ฐฝ์ด ๋œจ๊ณ  Create fork ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด ๋‚ด ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์— ์ค‘์•™ ์›๊ฒฉ ์ €์žฅ์†Œ์˜ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ๋ณต์ œํ•œ ๊ฒƒ๊ณผ ๊ฐ™์€ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๊ฐ€ ์ƒˆ๋กœ ์ƒ์„ฑ๋œ๋‹ค. 

    *fork๋ฅผ ์ทจ์†Œํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ๋‚ด๊ฐ€ ํฌํฌํ•œ ๋ฆฌํฌ๋กœ ๋“ค์–ด๊ฐ€ ์„ค์ •์—์„œ delete๋ฅผ ๋ˆ„๋ฅด๋ฉด ์‚ญ์ œ ๊ฐ€๋Šฅ.

     


    ๐Ÿ”— 2. clone: ๋‚ด ์›๊ฒฉ ์ €์žฅ์†Œ -> ๋‚ด ๋กœ์ปฌ ์ €์žฅ์†Œ

    ๋‚ด ์›๊ฒฉ ์ €์žฅ์†Œ๋ฅผ ๋ณต์ œํ•˜์—ฌ ๋กœ์ปฌ ์ €์žฅ์†Œ๋ฅผ ๋งŒ๋“œ๋Š” ๋ช…๋ น์–ด.

    git clone <๋‚ด remote repository URL>

    *์ฃผ์˜: ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๊ณ , ๊ทธ ํŒŒ์ผ์—์„œ ํ„ฐ๋ฏธ๋„์„ ์—ด์–ด ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค.

     


    ๐Ÿ”— 3. ๋‘๊ฐœ์˜ ์›๊ฒฉ ์ €์žฅ์†Œ๋ฅผ ์—ฐ๊ฒฐ

    git remote add upstream <์ค‘์•™ remote repository URL>

    -> remote add: ๋‚ด Git ์ €์žฅ์†Œ์— ์›๊ฒฉ ์ €์žฅ์†Œ(remote repository)๋ฅผ ์ถ”๊ฐ€ํ•˜๊ฒ ๋‹ค.

    -> upstream: ์ƒˆ๋กœ ์ถ”๊ฐ€ํ•˜๋Š” ์›๊ฒฉ ์ €์žฅ์†Œ์˜ ๋ณ„์นญ. ๋‚ด๊ฐ€ ์ •ํ•˜๋Š” ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— ๋‹ค๋ฅธ ์ด๋ฆ„์„ ์จ์ฃผ์–ด๋„ ๋จ. But, ๋ณดํ†ต ์ค‘์•™ ์›๊ฒฉ ์ €์žฅ์†Œ๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ upstream์ด๋ž€ ๋ณ„์นญ์„ ๋ถ™์ž„. 2๋ฒˆ์˜ ๋‚ด ์›๊ฒฉ ์ €์žฅ์†Œ๋Š” clone๊ณผ ๋™์‹œ์— ๊ธฐ๋ณธ์ ์œผ๋กœ origin ์ด๋ž€ ์ด๋ฆ„์ด ์ž๋™์œผ๋กœ ๋งŒ๋“ค์–ด์ง„๋‹ค. ์ด๋ ‡๊ฒŒ ๋‘๊ฐœ์˜ ์›๊ฒฉ ์ €์žฅ์†Œ๋ฅผ ์—ฐ๊ฒฐํ•ด ์ฃผ์–ด์•ผ์ง€๋งŒ ๋กœ์ปฌ ์ €์žฅ์†Œ๋ฅผ ํ”„๋กœ์ ํŠธ ์ค‘์•™ ์›๊ฒฉ ์ €์žฅ์†Œ์™€ ๊ฐ™์€ ์ƒํƒœ๋กœ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ๋‹ค. 

    *clone์„ ํ†ตํ•ด ์ƒ์„ฑ๋œ ํŒŒ์ผ์—์„œ ํ„ฐ๋ฏธ๋„์„ ์—ด์–ด ์ž‘์„ฑํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค. 

     

    git remote -v

    -> ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ํ˜„์žฌ ๋‚ด ๊นƒ ์ €์žฅ์†Œ์— ์„ค์ •๋œ ์›๊ฒฉ(remote) ์ €์žฅ์†Œ์˜ ๋ฆฌ์ŠคํŠธ๋ฅผ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

    git pull upstream <Branch Name>

    -> upstream ์›๊ฒฉ ์ €์žฅ์†Œ์˜ <Branch Name>์˜ ์ž‘์—…๋งŒ Pull ๋ฐ›๋Š”๋‹ค๋Š” ์˜๋ฏธ์ด๋‹ค. 

    git fetch upstream

    -> upstream ์›๊ฒฉ(remote) ์ €์žฅ์†Œ์˜ ๋ชจ๋“  ๋ธŒ๋žœ์น˜ ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๋ผ๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•œ๋‹ค.


     

    ๐Ÿ”— 4. ๋กœ์ปฌ ์ €์žฅ์†Œ์—์„œ ์ƒˆ๋กœ์šด ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑ

    ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑํ•˜๋Š” ์ด์œ : ์ผ๋ฐ˜์ ์œผ๋กœ๋Š” ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•  ๋•Œ๋งˆ๋‹ค ๊ธฐ๋Šฅ์„ ์ด๋ฆ„์œผ๋กœ ํ•˜์—ฌ ์ƒˆ๋กœ์šด ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑํ•œ๋‹ค. ํ•˜์ง€๋งŒ, ํ”„๋กœ์ ํŠธ ์ฐธ์—ฌ์ž๋ณ„๋กœ ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๊ฒฝ์šฐ๋„ ์žˆ๋‹ค. 

    git branch <๋‚ด๊ฐ€ ์›ํ•˜๋Š” branch ์ด๋ฆ„>

    -> ์ƒˆ๋กœ์šด ๋ธŒ๋žœ์น˜ ์ƒ์„ฑ. (์ƒˆ๋กœ์šด ๋ธŒ๋žœ์น˜๊ฐ€ ์ƒ์„ฑ๋  ๋•Œ ๋‚ด ์›๊ฒฉ ์ €์žฅ์†Œ์˜ ์ฝ”๋“œ๊ฐ€ ๋ณต์‚ฌ๋˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ ๋‚ด ๋กœ์ปฌ ์ €์žฅ์†Œ์˜ ์ฝ”๋“œ๊ฐ€ ๊ทธ๋Œ€๋กœ ๋ณต์‚ฌ๋˜์–ด ์ƒˆ๋กœ์šด ๋ธŒ๋žœ์น˜๋กœ ์˜ฎ๊ฒจ์ง€๋Š” ๊ฒƒ์ž„.)

    git checkout <์ด๋™ํ•˜๊ณ ์ž ํ•˜๋Š” branch ์ด๋ฆ„>

    -> ~~์ด๋ฆ„์˜ ๋ธŒ๋žœ์น˜๋กœ ์ด๋™.

    git checkout -b <branch name>

    -> <branch name>์ด๋ž€ ์ด๋ฆ„์˜ ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๋™์‹œ์— ์ด ๋ธŒ๋žœ์น˜๋กœ ์ด๋™.

     


    ๐Ÿ”— 5. ๋กœ์ปฌ ์ €์žฅ์†Œ์˜ ์ปค๋ฐ‹์„ ์ž์‹ ์˜ ์›๊ฒฉ ์ €์žฅ์†Œ์— ํ‘ธ์‹œ

    ๋ฐ”๋กœ ์ค‘์•™ ์›๊ฒฉ ์ €์žฅ์†Œ์— ์ž์‹ ์˜ ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•œ ์ฝ”๋“œ๋ฅผ ํ‘ธ์‹œํ•œ๋‹ค๋ฉด ๊ตณ์ด Organization๊ณผ Fork๋ฅผ ์‚ฌ์šฉํ•ด ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•œ ์ฝ”๋“œ๋“ค์„ ๋ถ„๋ฆฌํ•˜๋Š” ์ด์œ ๊ฐ€ ์‚ฌ๋ผ์ง„๋‹ค. ์ค‘์•™ ์›๊ฒฉ ์ €์žฅ์†Œ๊ฐ€ ์•„๋‹Œ ์ž์‹ ์˜ ์›๊ฒฉ ์ €์žฅ์†Œ์— ํ‘ธ์‹œํ•œ๋‹ค.

    git add . // ๋ณ€๊ฒฝ๋œ ๋ชจ๋“  ํŒŒ์ผ์„ ์Šคํ…Œ์ด์ง• ์˜์—ญ์— ์ถ”๊ฐ€ ํŒŒ์ผ ์ด๋ฆ„์ด๋‚˜ ๊ฒฝ๋กœ๋ฅผ ์ ์–ด์„œ ํŠน์ • ํŒŒ์ผ๋งŒ
    			์Šคํ…Œ์ด์ง• ์˜์—ญ์— ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ๋„ ๊ฐ€๋Šฅ.
    git commit -m "์ปค๋ฐ‹ ๋ฉ”์‹œ์ง€"

    * Git์—๋Š” ์„ธ๊ฐ€์ง€ ์˜์—ญ๊ณผ ์„ธ๊ฐ€์ง€ ์ƒํƒœ๊ฐ€ ์กด์žฌ.

     

    ์˜์—ญ

    Untracked area: Git์ด ๊ด€๋ฆฌํ•˜๊ณ  ์žˆ์ง€ ์•Š์€ ์˜์—ญ(ํŒŒ์ผ)

    Tracked area: Git์˜ ๊ด€๋ฆฌ๋ฅผ ๋ฐ›์„ ์ˆ˜ ์žˆ๋Š” ์˜์—ญ(ํŒŒ์ผ)

    Staging area: Commit์ด ๊ฐ€๋Šฅํ•œ ์˜์—ญ(ํŒŒ์ผ)

     

    ์ƒํƒœ

    Unmodified: ๊ธฐ์กด์— ์ปค๋ฐ‹ ํ–ˆ๋˜ ํŒŒ์ผ์„ ์ˆ˜์ •ํ•˜์ง€ ์•Š์€ ์ƒํƒœ

    Modified: ๊ธฐ์กด์— ์ปค๋ฐ‹ํ–ˆ๋˜ ํŒŒ์ผ์„ ์ˆ˜์ •ํ•œ ์ƒํƒœ

    Staged: Commit์ด ๊ฐ€๋Šฅํ•œ ์ƒํƒœ

     

    => git add ๋ช…๋ น์–ด๋Š” tracked area์˜ modified๋œ ์ƒํƒœ์˜ ํŒŒ์ผ์„ staging area๋กœ ์˜ฎ๊ฒจ์ฃผ์–ด staged์ƒํƒœ๋กœ ๋ณ€๊ฒฝํ•ด์ฃผ๋Š” ๋ช…๋ น์–ด๋ผ๊ณ  ๋ณด๋ฉด๋จ.

    git push origin <branch name>

    -> ์ˆ˜์ •ํ•œ ์ฝ”๋“œ๊ฐ€ ์žˆ๋Š” ์›๊ฒฉ ์ €์žฅ์†Œ์˜ ๋ธŒ๋žœ์น˜์— ํ‘ธ์‹œ

     


    ๐Ÿ”— 6. Pull Request

    ์ธํ„ฐ๋„ท์„ ํ†ตํ•ด ๋‚ด๊ฐ€ Forkํ•œ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋กœ ๊ฐ€์„œ admin์—๊ฒŒ pull request๋ฅผ ๋ณด๋‚ธ๋‹ค. branch ์„ ํƒ ๊ฐ€๋Šฅ.

    (์†Œ๊ทœ๋ชจ ํ”„๋กœ์ ํŠธ์—์„  ๋ชจ๋‘๊ฐ€ admin์ด ๋  ์ˆ˜ ์žˆ๋‹ค.)

     


    ๐Ÿ”— 7. ํ”„๋กœ์ ํŠธ ๊ด€๋ฆฌ์ž(admin)์€ pull request์˜ ๋ณ€๊ฒฝ ๋‚ด์šฉ์„ ํ™•์ธํ•˜๊ณ  ์ค‘์•™ ์›๊ฒฉ ์ €์žฅ์†Œ์— ๋ณ‘ํ•ฉ(merge)ํ•œ๋‹ค. 

    Github ํŽ˜์ด์ง€์—์„œ Pull request ๋ฒ„ํŠผ์„ ํด๋ฆญ ํ›„, File changed ํƒญ์—์„œ ๋ณ€๊ฒฝ ๋‚ด์šฉ์„ ํ™•์ธํ•˜์—ฌ Conversation ํƒญ์œผ๋กœ ์ด๋™ํ•˜์—ฌ "Confirm merge"๋ฅผ ํ•˜๋ฉด ์ค‘์•™ ์›๊ฒฉ ์ฝ”๋“œ ๋ฒ ์ด์Šค์— ๋ณ‘ํ•ฉ(merge)๋œ๋‹ค. ์ถฉ๋Œ์ด ๋ฐœ์ƒํ•˜๋Š” ๊ฒฝ์šฐ์—” ํŒ€์›๋“ค๊ณผ ์˜๋…ผํ•˜์—ฌ ์ถฉ๋Œ ๋‚ด์šฉ์„ ์ˆ˜์ • ํ›„ ๋ณ‘ํ•ฉ.

     


    ๐Ÿ”— 8. ์ค‘์•™ ์›๊ฒฉ ์ €์žฅ์†Œ์™€ ์ž์‹ ์˜ ๋กœ์ปฌ ์ €์žฅ์†Œ๋ฅผ ๋™๊ธฐํ™” ํ•˜๊ธฐ ์œ„ํ•ด ๋กœ์ปฌ ์ €์žฅ์†Œ์˜ branch๋ฅผ ๊ธฐ๋ณธ ๋ธŒ๋žœ์น˜(์ตœ์ข… ์ฝ”๋“œ๋ฅผ ๋„ฃ๋Š” ๋ธŒ๋žœ์น˜)๋กœ ์ด๋™(checkout) ํ›„ pull

    git pull upstream main

    ๐Ÿ”— 9. ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•˜๊ธฐ ์œ„ํ•ด ๋˜ ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑ(๋ฐ˜๋ณต)

    8๋ฒˆ์„ ํ†ตํ•ด ์ค‘์•™ ์›๊ฒฉ ์ €์žฅ์†Œ์™€ ๋™๊ธฐํ™”๋œ ๋กœ์ปฌ ์ €์žฅ์†Œ์˜ main ๋ธŒ๋žœ์น˜์—์„œ ์ƒˆ๋กœ์šด ๋ธŒ๋žœ์น˜๋ฅผ ํ•˜๋‚˜ ๋” ํŒŒ์„œ ์ž‘์—…์„ ์‹œ์ž‘.


    ๐Ÿ”—  References

    https://kotlinworld.com/265

    https://gmlwjd9405.github.io/2017/10/28/how-to-collaborate-on-GitHub-2.html

    https://ittrue.tistory.com/94

Designed by Tistory.