Git(2)

Bonnie Ryuยท2020๋…„ 10์›” 29์ผ
0

๐Ÿ™‹โ€โ™€๏ธ ์•Œ์•„๋ณผ ๋‚ด์šฉ

  • Git ๊ธฐ๋ณธ ๋ช…๋ น์–ด(2) - clone, pull request(PR), conflicts, pull

๐Ÿงถ Git ๊ธฐ๋ณธ ๋ช…๋ น์–ด(2)

๐Ÿพย ย clone

github์— ์žˆ๋Š” ์ €์žฅ์†Œ(repository)๋ฅผ ๋กœ์ปฌ๋กœ ๋‹ค์šด๋กœ๋“œํ•˜๋Š” ๊ฒƒ์„ "๋ณต์ œ(clone)ํ•œ๋‹ค"๋ผ๊ณ  ๋งํ•œ๋‹ค.

ํ•ด๋‹น remote repository ๋ฅผ ๋‚ด ์ปดํ“จํ„ฐ๋กœ ๋ฐ›์•„์˜ค๊ธฐ ์œ„ํ•ด,
ํ•ด๋‹น repo ๋ฅผ ๋‹ค์šด๋กœ๋“œ ๋ฐ›๊ณ  ์‹ถ์€ ๊ฒฝ๋กœ๋กœ ์ด๋™ํ•œ ๋’ค git clone ๋ช…๋ น์–ด์— ๋ฐฉ๊ธˆ ๋ณต์‚ฌํ•ด์ค€ URL ์„ ๋ถ™์—ฌ์ฃผ๊ณ  ์‹คํ–‰ํ•œ๋‹ค.
๋‚˜๋Š” github์— ์žˆ๋Š” ThisIsTest repo๋ฅผ ํด๋ก ํ•ด๋ณด์•˜๋‹ค.

์ž‘์„ฑ์ˆœ์„œ : git clone {ํ•ด๋‹น ๋ ˆํฌ์ง€ํ† ๋ฆฌ ์ฃผ์†Œ}

$ ~/Desktop/git-test  git clone https://github.com/ryuwisdom/ThisIsTest.git
'ThisIsTest'์— ๋ณต์ œํ•ฉ๋‹ˆ๋‹ค...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 6 (delta 0), pack-reused 0
์˜ค๋ธŒ์ ํŠธ ๋ฌถ์Œ ํ‘ธ๋Š” ์ค‘: 100% (6/6), 638 bytes | 106.00 KiB/s, ์™„๋ฃŒ.

cloneํ›„ git-testํด๋”์— ThisIsTestํด๋”๊ฐ€ ์ƒ์„ฑ๋˜์—ˆ๋‹ค.
์ด์ฒ˜๋Ÿผ clone ์„ ํ•˜๋ฉด GitHub repo ์˜ ์ด๋ฆ„์„ ๊ทธ๋Œ€๋กœ ๋”ด ํด๋”๊ฐ€ ์ƒ์„ฑ๋˜๊ณ  cd ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•ด ํ•ด๋‹น ํด๋”๋กœ ์ด๋™ํ•˜๋ฉด, clone ์‹œ์ ์— remote repo์— ์กด์žฌํ–ˆ๋˜ ๋ชจ๋“  ํด๋” ๋ฐ ํŒŒ์ผ๋“ค์ด ๊ทธ๋Œ€๋กœ ๋ณต์ œ๋˜์–ด ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

์ด์ œ Git(1)์—์„œ ์‚ดํŽด๋ณด์•˜๋˜ flow ํ›„ PR์„ ํ•  ๊ฒƒ์ด๋‹ค.

- git add โ€ฃ git commit โ€ฃ git push

 ~/Desktop/git-test/ThisIsTest ryu git add .                
 ~/Desktop/git-test/ThisIsTest ryuโœš git commit -m 'add emoji'
[ryu 5a4b34e] add emoji
 Committer: ๋ฅ˜์ง€ํ˜œ <ryujihye@lyujihyeui-MacBook-Pro.local>
์ด๋ฆ„๊ณผ ์ „์ž๋ฉ”์ผ ์ฃผ์†Œ๋ฅผ ์‚ฌ์šฉ์ž ์ด๋ฆ„๊ณผ ํ˜ธ์ŠคํŠธ ์ด๋ฆ„์„ ์ด์šฉํ•ด์„œ ์ž๋™์œผ๋กœ
์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด ์ •๋ณด๊ฐ€ ๋งž๋Š”์ง€ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค. ์ด ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด์ง€ ์•Š์œผ๋ ค๋ฉด ์ •๋ณด๋ฅผ
๋ช…์‹œ์ ์œผ๋กœ ์„ค์ •ํ•˜์‹ญ์‹œ์˜ค. ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ํŽธ์ง‘๊ธฐ์˜ ์•ˆ๋‚ด์— ๋”ฐ๋ผ ์„ค์ •
ํŒŒ์ผ์„ ํŽธ์ง‘ํ•˜์‹ญ์‹œ์˜ค:

    git config --global --edit

์ด๋ ‡๊ฒŒ ํ•œ ๋‹ค์Œ, ์ด ์ปค๋ฐ‹์— ์‚ฌ์šฉํ•œ ์‹ ์› ์ •๋ณด๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํ•ด์„œ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+), 1 deletion(-)
 ~/Desktop/git-test/ThisIsTest ryu git push origin ryu
์˜ค๋ธŒ์ ํŠธ ๋‚˜์—ดํ•˜๋Š” ์ค‘: 5, ์™„๋ฃŒ.
์˜ค๋ธŒ์ ํŠธ ๊ฐœ์ˆ˜ ์„ธ๋Š” ์ค‘: 100% (5/5), ์™„๋ฃŒ.
Delta compression using up to 4 threads
์˜ค๋ธŒ์ ํŠธ ์••์ถ•ํ•˜๋Š” ์ค‘: 100% (3/3), ์™„๋ฃŒ.
์˜ค๋ธŒ์ ํŠธ ์“ฐ๋Š” ์ค‘: 100% (3/3), 353 bytes | 353.00 KiB/s, ์™„๋ฃŒ.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
remote: 
**remote: Create a pull request for 'ryu' on GitHub by visiting:**
remote:      https://github.com/ryuwisdom/ThisIsTest/pull/new/ryu
remote: 
To https://github.com/ryuwisdom/ThisIsTest.git
 * [new branch]      ryu -> ryu
 ~/Desktop/git-test/ThisIsTest ryu 

์ด์ œ PR์„ ํ•  ์ˆ˜ ์žˆ๋Š” ์ƒํƒœ๊ฐ€ ๋˜์—ˆ๋‹ค!
PR์ด ๋ฌด์—‡์ธ์ง„ ์•„๋ž˜์— ๐Ÿ™ ๐Ÿ‘‡

๐Ÿพย ย pull-request(PR)

๋‚˜์˜ ๋ธŒ๋žœ์น˜์™€ ๊ธฐ๋ณธ ๋ธŒ๋žœ์น˜์ธ Master ๋ธŒ๋žœ์น˜์™€ merge์ „ ๊ฑฐ์ณ์•ผ ํ•˜๋Š” ๋‹จ๊ณ„์ด๋‹ค.

์ž์‹ ์˜ ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑํ•˜์—ฌ push ํ•˜๊ณ  master ๋ธŒ๋žœ์น˜์— ์ ์šฉ๋  ์ค€๋น„๊ฐ€ ๋˜์—ˆ๋‹ค๋ฉด, Pull Request (PR) ๋ผ๋Š” ๊ฒƒ์„ ํ†ตํ•ด ํ”„๋กœ์ ํŠธ ์˜ค๋„ˆ (ํ˜น์€ ํŒ€ ๋ฆฌ๋”) ์—๊ฒŒ ๋‚ด๊ฐ€ ์ž‘์—…ํ•œ ๋ธŒ๋žœ์น˜์˜ ์ž‘์—…๋‚ด์šฉ์„ master ๋ธŒ๋žœ์น˜์— ๋ฐ˜์˜ํ•ด๋‹ฌ๋ผ๋Š” ์š”์ฒญ์„ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋‹ค.

Pull Request ์—์„œ๋Š” ํ•ด๋‹น repository ๋ฅผ ์—ด๋žŒํ•  ์ˆ˜ ์žˆ๋Š” ๊ถŒํ•œ์ด ์žˆ๋Š” ๊ฐœ๋ฐœ์ž๋“ค์ด ์ž‘์—…๋‚ด์šฉ์— ๋Œ€ํ•œ ๋ฆฌ๋ทฐ๋ฅผ ํ•ด์ฃผ๊ฑฐ๋‚˜, ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ํ™•์ธํ•œ๋‹ค. (master ๋ธŒ๋žœ์น˜๋กœ ํ•ฉ์ณ์ง€๊ธฐ ์ „์— ํ™•์ธํ•ด์•ผํ•˜๊ธฐ ๋•Œ๋ฌธ์—)

ํ•ด๋‹น ๋งํฌ๋ฅผ ํด๋ฆญํ•˜๋ฉด, Pull Request ๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋Š” ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•˜์—ฌ ํ•ด๋‹น PR์˜ ์ œ๋ชฉ๊ณผ ์–ด๋–ค ๋‚ด์šฉ์„ ๋‹ด๊ณ  ์žˆ๋Š”์ง€ ์„ค๋ช…ํ•˜๋Š” Description์„ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค.

์ž‘์„ฑ์„ ์™„๋ฃŒํ–ˆ๋‹ค๋ฉด, ํ•˜๋‹จ์— 'Create pull request' ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ๋งˆ๋ฌด๋ฆฌ.
์ด๋•Œ๋ถ€ํ„ฐ๋Š” ํ•จ๊ป˜ ํ˜‘์—…ํ•˜๋Š” ๊ฐœ๋ฐœ์ž๋“ค์ด ๋ฐฉ๊ธˆ ๋งŒ๋“  PR์„ ๋ฆฌ๋ทฐํ•˜๊ณ  ํ”ผ๋“œ๋ฐฑ์„ ์ฃผ๊ณ  ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค.

๋ชจ๋“  ๋ฆฌ๋ทฐ ๋‚ด์šฉ์ด ๋ฐ˜์˜๋œ ํ›„ master ๋ธŒ๋žœ์น˜์™€ ์ถฉ๋Œ์ด ๋ฐœ์ƒํ•˜์ง€ ์•Š์•˜๋‹ค๋ฉด, ํ•ด๋‹น PR์€ master ๋ธŒ๋žœ์น˜๋กœ merge ๋  ์ƒํƒœ๐ŸŒŸ

๐Ÿพย ย conflicts

ํ•ญ์ƒ ์ด๋ ‡๊ฒŒ ์ˆœ์กฐ๋กญ๊ฒŒ merge ๊นŒ์ง€ ์ง„ํ–‰๋˜๋ฉด ๋„ˆ๋ฌด ์ข‹๊ฒ ์ง€๋งŒ, merge ํ•˜๊ธฐ ์ „ conflicts (์ถฉ๋Œ) ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค. ์ถฉ๋Œ์€ ์–ด๋–ค ํŒŒ์ผ์˜ ๋ณ€๊ฒฝ์‚ฌํ•ญ์ด ๊ธฐ์ค€์ด ๋˜๋Š” master ๋ธŒ๋žœ์น˜์˜ ํŒŒ์ผ๊ณผ ๊ฒน์ณ, Git ์—์„œ ์–ด๋–ค ๋ฒ„์ „์˜ ์ฝ”๋“œ๋ฅผ ์„ ํƒํ•ด์•ผํ•˜๋Š”์ง€ ๋ชจ๋ฅผ ๋•Œ ๋ฐœ์ƒํ•œ๋‹ค. ์ด๋Ÿฐ ์ƒํ™ฉ์—์„œ๋Š”, ๊ฐœ๋ฐœ์ž๊ฐ€ ์ง์ ‘ ์ฝ”๋“œ๋ฅผ ๋น„๊ตํ•ด ์ถฉ๋Œ์„ ํ•ด๊ฒฐํ•˜๊ณ  merge ๋ฅผ ๋งˆ๋ฌด๋ฆฌ ํ•ด์•ผํ•œ๋‹ค.

๐Ÿพย ย pull

Pull Request ๋ฅผ ํ†ตํ•ด master ๋ธŒ๋žœ์น˜๋ฅผ ์—…๋ฐ์ดํŠธํ–ˆ๋‹ค๋ฉด, ์ด์ œ ๋กœ์ปฌ repository ๋Š” GitHub ์— ์žˆ๋Š” master ์™€ ์„œ๋กœ ๋‹ค๋ฅธ ๋‚ด์šฉ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์ƒํƒœ์ด๋‹ค. ์ด ๋•Œ git pull ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด remote ์˜ ์ตœ์‹ ํ™”๋œ ์ฝ”๋“œ๋ฅผ ๋‚ด ๋กœ์ปฌ repo ์— ๋ฐ˜์˜ํ•  ์ˆ˜ ์žˆ๋‹ค.

์šฐ๋ฆฌ๋Š” GitHub remote repo ๋งํฌ์— origin ์ด๋ผ๋Š” ์ด๋ฆ„์„ ๋ถ™์—ฌ์คฌ์—ˆ๊ธฐ ๋•Œ๋ฌธ์— ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด GitHub repo ์˜ master ๋ธŒ๋žœ์น˜ ๋‚ด์šฉ์„ ๋ฐ›์•„์˜ฌ ์ˆ˜ ์žˆ๋‹ค.

git pull origin master

git pull ์ž‘์—… ํ›„ ๋‚˜์˜ ์ž‘์—… ๋‚ด์šฉ๊ณผ ํ˜‘์—…์ž๋“ค์˜ ์ž‘์—… ๋‚ด์šฉ์ด merge๋œ ์ตœ์‹ ์˜ ํŒŒ์ผ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.



3ํƒ„์€ Git ์‚ฌ์šฉ์— ๋Œ€ํ•œ ๊ฟ€ํŒ์ด ์ค€๋น„๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค! ๐Ÿฐ โœจ

profile
Ryuwisdom

0๊ฐœ์˜ ๋Œ“๊ธ€