- git push์ ์ ํํ ์๋ฏธ๊ฐ ๋ฌด์์ธ๊ฐ?
- git pull์ ์ ํํ ์๋ฏธ๊ฐ ๋ฌด์์ธ๊ฐ?
- git push์ ์ ํํ ์๋ฏธ๊ฐ ๋ฌด์์ธ๊ฐ?
- git push๋ ์ ํํ๊ฒ ๋งํ๋ฉด, push๋ฅผ ํ๋ ค๋ branch์ commit ์ํฉ์ push๋ฅผ ๋นํ๋ branch์ ๋ฐ์ด๋ฃ๋ ์ก์ ์ด๋ค.
๋ฐ์ด๋ฃ์ ๋๋ ๋น์ฐํ ๋ branch์ ์ ์ฒด์ ์ธ commit ์ํฉ์ด ๊ฐ์์ผ ํ๊ณ ,
๊ฐ์ ํ์ผ์ ๋ํด์ commit ์ํฉ์ด ๋ค๋ฅธ ํ์ผ์ด ์๋ค๋ฉด push ํ๋ ค๋ branch๊ฐ ์ฐ์ ์ ๋๋ค. ๋ฐ๋ผ์, push ๋นํ๋ branch๋ ๋ณ๊ฒฝ์ ์ด ์์ผ๋ฉด ์๋๋ค (์์ผ๋ฉด conflict) conflict์ด ๋๋ ์ด์ ๋ git์ด ๊ฐ์ ํ์ผ์ ๋ํ ๋ค๋ฅธ commit ์ค ์ด๋ ๊ฒ์ ๋ฐ๋ผ์ผ ํ๋์ง ์ ์ ์๊ธฐ ๋๋ฌธ์ด๋ค.
- git pull์ ์ ํํ ์๋ฏธ๊ฐ ๋ฌด์์ธ๊ฐ?
- git pull์ ์ ํํ git fetch + merge ์ด๋ค. git fecth๋ ๋จ์ํ ์์ค reposit์์ commit ๋ค์ ๊ฐ์ ธ์ค๋ ํ์์ ํด๋นํ๊ณ
merge๋ ๊ฐ์ ธ์จ commit๊ณผ ํฉ์น๋ ค๋ branch์ commit์ ํ๊ตฐ๋ฐ๋ก ํฉ์น๋ ๊ฒ์ ์๋ฏธํ๋ค. (ํฉ์น๋ ๊ณผ์ ์์ git์ด ํท๊ฐ๋ฆด๋งํ ์ํฉ์ด ๋ฐ์ํ๋ฉด issue/conflict ๋ฐ์)
๋ค์ ๋งํด, git pull ์ ์์ค branch๊ฐ ์ฃผ๊ถ์ด ์์ด์ ์ฌ๊ธฐ์ ๊ธฐ์ค์ ๋ง์ถฐ์ merge๋ฅผ ์งํํ๋ค. (๋์ผ ํ์ผ์ ๋ํด ๋ณ๊ฒฝ์ ์ด ์๋ค๋ฉด ์์ค branch์ ๋ณ๊ฒฝ์ ์ ๋ฐ๋ฅธ๋ค)
- Remote reposit A ์์ฑ โ
- remote A ์์ a.txt ์์ฑ ํ commit โ
- local ์์ reposit A clone โ
- remote A ์์ b.txt ์์ฑ ํ commit
- local A ์์ c.txt ์์ฑ ํ commit
- ์ฌ๊ธฐ์ local A ์์ remote A๋ก push ํ๋ ค๊ณ ํ๋ฉด ๊ณผ์ฐ conflict์ด ๋๋๊ฐ?
- conflict์ด ๋๋ค๋ฉด local A์ ์๊ณ remote A์ ์กด์ฌํ๋ b.txt ๋๋ฌธ์ธ๊ฐ? ์๋๋ฉด ๋ฐ๋์ธ c.txt ๋๋ฌธ์ธ๊ฐ?
- ์ฌ๊ธฐ์ local A ์์ remote A๋ก push ํ๋ ค๊ณ ํ๋ฉด ๊ณผ์ฐ conflict์ด ๋๋๊ฐ?
- ๋ง๋ค. conflict์ด ๋๋ค. git push๋ฅผ ํ๊ธฐ ์ ์๋ git pull(fetch+merge) ๋ฅผ ํตํด push ํ๋ branch์ push ๋นํ๋ branch์ commit ์ํฉ์ ๋ง์ถ ํ์๊ฐ ์๋ค
local A๋ git์ด a.txt ์ c.txt ํ์ผ๋ค์ ํธ๋ํน ์ค์ด๋ฉฐ, remote A๋ git์ด a.txt์ b.txt ์ ๋ํด ํธ๋ํน ์ค์ด๋ค. ๊ณ ๋ก ์ ์ฒด์ ์ธ commit ์ํฉ์ด ๊ฐ์ง ์์ผ๋ฏ๋ก push๊ฐ ๋ถ๊ฐ๋ฅํ๋ค
- ๊ทธ๋ ๋ค๋ฉด git pull ์ issue๊ฐ ๋์ง ์๋๊ฐ?
- ์๋๋ค. issue๊ฐ ๋๋ค. ๋ง์ฐฌ๊ฐ์ง๋ก local A๋ a.txt ์ c.txt๋ฅผ remote A๋ a.txt ์ b.txt ๋ฅผ ํธ๋ํน์ค์ด๋ฏ๋ก ํ์ผ ํธ๋ํน์ ๋ํ conflict์ ์์ง๋ง ์ ์ฒด์ ์ธ commit ์ํฉ์ด ๋ค๋ฅด๋ฏ๋ก issue๊ฐ ๋ฐ์ํ๋ค๊ณ ๋ณผ ์ ์๋ค. ํ์ง๋ง ํ์ผ conflict์ด ์๋๋ฏ๋ก git์ ๊ธฐ๋ณธ์ค์ ์ ๋ฐ๊ฟ์ rebase ์๋ ๊ธฐ๋ฅ (git config pull.rebase true)์ ํค๋ฉด git์ด ์๋์ผ๋ก issue๊ฐ ๋ ๋ถ๋ถ์ rebase ํ๊ณ merge๋ฅผ ์์ผ์ฃผ๋ฉด์ pull์ ํด์ค๋ค.