๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿคผ Git

[Git] ์—ฌ๋Ÿฌ ๋ ˆํฌ์ง€ํ† ๋ฆฌ ํ•˜๋‚˜๋กœ ํ•ฉ์น˜๊ธฐ(Merge multiple repository)

by Fomagran ๐Ÿ’ป 2021. 8. 14.
728x90
๋ฐ˜์‘ํ˜•

 

์•ˆ๋…•ํ•˜์„ธ์š” Foma๐Ÿ‘Ÿ ์ž…๋‹ˆ๋‹ค!

 

์˜ค๋Š˜์€ ์—ฌ๋Ÿฌ ๋ ˆํฌ์ง€ํ† ๋ฆฌ๋ฅผ ํ•˜๋‚˜๋กœ ํ•ฉ์น˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณผ๊ฑด๋ฐ์š”.

 

์˜ˆ์ „์— ํ”Œ๋Ÿฌํ„ฐ ๊ณต๋ถ€ํ•˜๋˜ ๊ฐ„๋‹จํ•œ ๋ฏธ๋‹ˆ ํ”„๋กœ์ ํŠธ๋“ค์ด ๋งŽ์ด ์Œ“์—ฌ์„œ ์ด๊ฑธ ํ•˜๋‚˜์˜ Flutter Example์ด๋ผ๋Š” ๋ ˆํฌ์ง€ํ† ๋ฆฌ๋กœ

 

ํ•ฉ์น˜๊ณ  ์‹ถ๋”๋ผ๊ตฌ์š”.

 

๊ทธ๋ž˜์„œ ์˜ค๋Š˜์€ ์ด๋ ‡๊ฒŒ ํ•˜๋‚˜๋กœ ํ•ฉ์น˜๋Š” ๊ณผ์ •์— ๋Œ€ํ•ด์„œ ์ •๋ฆฌํ•˜๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!

 

๋ฐ”๋กœ ์‹œ์ž‘ํ• ๊ฒŒ์š”~


Github

 

๋จผ์ € Github ์‚ฌ์ดํŠธ๋กœ ์ด๋™ํ•ด์ฃผ์„ธ์š”.

 

 

GitHub: Where the world builds software

GitHub is where over 65 million developers shape the future of software, together. Contribute to the open source community, manage your Git repositories, review code like a pro, track bugs and feat...

github.com

 

์ƒˆ๋กญ๊ฒŒ ํ•ฉ์น  ๋ ˆํฌ์ง€ํ† ๋ฆฌ๋ฅผ ํ•˜๋‚˜ ์ƒ์„ฑํ•ด์ค๋‹ˆ๋‹ค. (์ดˆ๋ก์ƒ‰ New ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.)

 

 

์ƒˆ๋กœ์šด ๋ ˆํฌ์ง€ํ† ๋ฆฌ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”!

 

 

 

๊ทธ ๋‹ค์Œ ์ƒ์„ฑ๋œ ๋ ˆํฌ์ง€ํ† ๋ฆฌ git ์ฃผ์†Œ๋ฅผ ๋ณต์‚ฌํ•ด์ค๋‹ˆ๋‹ค.

 

์ดˆ๋ก์ƒ‰ Code ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด HTTPS ์ฃผ์†Œ๊ฐ€ ๋‚˜์™€์š” ์ด๊ฑธ ๋ณต์‚ฌํ•ด์ค๋‹ˆ๋‹ค.

 


Terminal

 

์ด์ œ ํ„ฐ๋ฏธ๋„๋กœ ์ด๋™ํ•ด์ฃผ์„ธ์š”.

 

ํ„ฐ๋ฏธ๋„์„ ์ผœ์„œ ์œ„์—์„œ ๋ณต์‚ฌํ•ด์ค€ ์ฃผ์†Œ๋ฅผ git clone ํ•ด์ค๋‹ˆ๋‹ค.

 

git clone https://github.com/fomagran/Flutter-Example.git

 

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์ƒˆ๋กœ์šด ํด๋ก ํ•œ ํด๋”๊ฐ€ ์ƒˆ๋กญ๊ฒŒ ์ƒ๊ฒผ์„๊ฑฐ์—์š”.

 

ํ•ด๋‹น ํด๋”๋กœ ์ด๋™ํ•ด์ค๋‹ˆ๋‹ค.

 

cd Desktop/Flutter/Flutter-Example/

Github

 

๊นƒํ—™์œผ๋กœ ์ด๋™ํ•ด์„œ ์ƒˆ๋กœ์šด ๋ ˆํฌ์ง€ํ† ๋ฆฌ์— ํ•ฉ์น  ๋ ˆํฌ์ง€ํ† ๋ฆฌ์˜ ์ฃผ์†Œ๋ฅผ ๋ณต์‚ฌํ•ด์ฃผ์„ธ์š”.

 

์ „ Flutter ๋ฏธ๋‹ˆ ํ”„๋กœ์ ํŠธ ์ค‘ ํ•˜๋‚˜์ธ i_am_rich๋ผ๋Š” ํ”„๋กœ์ ํŠธ์— ๋„ฃ์–ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

ํ„ฐ๋ฏธ๋„๋กœ ๋‹ค์‹œ ๋Œ์•„์™€์„œ ์•„๋ž˜์™€ ๊ฐ™์ด 

 

git subtree add --preix="๋ ˆํฌ์ง€ํ† ๋ฆฌ ์ด๋ฆ„" "๋ ˆํฌ์ง€ํ† ๋ฆฌ ๊นƒ ์ฃผ์†Œ" "๋ธŒ๋žœ์น˜ ์ด๋ฆ„" ์„ ์ ์–ด์ค๋‹ˆ๋‹ค.

 

git subtree add --prefix=i_am_rich https://github.com/fomagran/i_am_rich.git master

 

๋งŒ์•ฝ ์•„๋ž˜์™€ ๊ฐ™์ด Working tree has modifications. Cannot add ๋ผ๋Š” ์˜ค๋ฅ˜๊ฐ€ ๋œจ์‹  ๋ถ„๋“ค์€ ์•„์ง ์ƒˆ๋กญ๊ฒŒ ๋งŒ๋“  ๋ ˆํฌ์ง€ํ† ๋ฆฌ๊ฐ€

 

์—…๋ฐ์ดํŠธ๊ฐ€ ์•ˆ๋˜์—ˆ๋‹ค๋Š” ์†Œ๋ฆฐ๋ฐ์š”.

 

 

 

์ด๊ฒƒ์€ git push ๋˜๋Š” git checkout "๊ฐ€์žฅ ์ตœ๊ทผ์˜ ์ปค๋ฐ‹์ฃผ์†Œ(?)"๋ฅผ ํ•ด์ค˜์„œ ์—…๋ฐ์ดํŠธ๋ฅผ ํ•ด์ค๋‹ˆ๋‹ค.

 

 

์œ„์™€ ๊ฐ™์ด ํ–ˆ๋Š”๋ฐ๋„ ์—ฌ์ „ํžˆ Working tree has modifications. Cannot add ๋œฌ๋‹คํ•˜์‹œ๋Š” ๋ถ„๋“ค์€ ์•„๋ž˜์™€ ๊ฐ™์ด

 

์ปค๋ฐ‹์„ ์•„๋ฌด๊ฑฐ๋‚˜ ๋„ฃ์€ ๋’ค ์ง„ํ–‰ํ•ด์ฃผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

 

$ git add .
$ git commit -m '์ปค๋ฐ‹ ๋‚ด์šฉ ์•„๋ฌด๊ฑฐ๋‚˜'

 

 

 

 

(ํ˜น์‹œ git push๋ฅผ ํ•  ๋•Œ ์•„๋ž˜์™€ ๊ฐ™์€ ์˜ค๋ฅ˜๊ฐ€ ์ƒ๊ธฐ์‹œ๋Š” ๋ถ„๋“ค์€ ์—ฌ๊ธฐ ์—์„œ ํ™•์ธํ•ด์ฃผ์„ธ์š”!)

 

 

์ด๋ ‡๊ฒŒ git push๋ฅผ ํ•ด์ฃผ์‹  ๋‹ค์Œ์— ๋‹ค์‹œ ํ•ด์ฃผ์‹œ๋ฉด

 

git subtree add --prefix=i_am_rich https://github.com/fomagran/i_am_rich.git master

 

๋‹ค์Œ๊ณผ ๊ฐ™์ด ์„ฑ๊ณต์ ์œผ๋กœ ์ถ”๊ฐ€๊ฐ€ ๋˜์—ˆ๋‹ค๊ณ  ๋œน๋‹ˆ๋‹ค.

 

 

๊ทธ๋ฆฌ๊ณ  ๋งˆ์ง€๋ง‰์œผ๋กœ ํ•ฉ์ณ์ง„ ๋ ˆํฌ์ง€ํ† ๋ฆฌ๋ฅผ ํ‘ธ์‰ฌํ•ด์ค๋‹ˆ๋‹ค.

 

$ git push origin HEAD:main

 

 

์ด์ œ Github์œผ๋กœ ๊ฐ€์„œ ํ™•์ธํ•ด๋ณผ๊นŒ์š”?

 

์ƒˆ๋กญ๊ฒŒ ๋งŒ๋“ค์–ด์ค€ Flutter-Example ๋ ˆํฌ์ง€ํ† ๋ฆฌ์— i_am_rich ํ”„๋กœ์ ํŠธ๊ฐ€ ์ถ”๊ฐ€๋œ ๊ฑธ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!

 


์˜ค๋Š˜์€ ์ด๋ ‡๊ฒŒ ์ƒˆ๋กœ์šด ๋ ˆํฌ์ง€ํ† ๋ฆฌ๋ฅผ  ๋งŒ๋“ค๊ณ  ๊ธฐ์กด์— ์žˆ๋˜ ์—ฌ๋Ÿฌ ๋ ˆํฌ์ง€ํ† ๋ฆฌ๋ฅผ ํ•˜๋‚˜๋กœ ํ•ฉ์น˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด์•˜์Šต๋‹ˆ๋‹ค.

 

ํ˜น์‹œ๋ผ๋„ ๊ถ๊ธˆํ•˜์‹  ์ ์ด ์žˆ๋‹ค๋ฉด ๋Œ“๊ธ€๋กœ ์•Œ๋ ค์ฃผ์„ธ์š”~

728x90
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€