
์๋ก์ด ๋ก์ปฌ ๊ณต๊ฐ์์ ์์ ์ ํ ๊ฒฝ์ฐ Remote๊ณต๊ฐ์ ์๋ ์์ค๊ฐ ํ์ํ๋ค.
โ1. git clone
โ
Remote์ ์ ์ฅ๋ ์์ ํ์ผ์ ํต์งธ๋ก Local๋ก ๊ฐ์ ธ์จ๋.
1) ์ฒ์ ํ๋ก์ ํธ์ ํฌ์ ๋๊ฑฐ๋
2) ์ฑ ์์ ์ ๊ณตํ๋ ์์ ์์ค๋ฅผ ๊ฐ์ ธ์ฌ ๋
3) ์ค๊ฐ์ git์ด ๊ผฌ์์ ๋ ์ฌ์ฉํ๋ค.
git clone https://github.com/repository
// ํน์ ๋ธ๋์น๋ฅผ clone ํ๊ณ ์ถ์ ๋
git clone -b { ๋ธ๋์น๋ช
} https://github.com/repository
//node-opencv ์คํ์์ค๋ฅผ cloneํ๊ณ ์ถ์ ๋
git clone https://github.com/peterbraden/node-opencv.git
2. git clone VS git pull
โ
๊ณตํต์ : remote repository์ ์๋ ํ์ผ๋ค์ local๋ก ๊ฐ์ ธ์จ๋ค.
1) git clone
: Remot Repository์ ๋ชจ๋ ํ์ผ๋ค์ ๊ฐ์ ธ์ค๊ธฐ๋ง ํ๋ค.

โ
2) git pull
: Local Repository์ ๋น๊ต, ๋ณํฉ ํ์ ์ ์ฅํ๋ค.
git pull { ์๊ฒฉ ์ ์ฅ์ ๋ณ๋ช
} { ๋ธ๋์น๋ช
}
git pull --rebase { ์๊ฒฉ ์ ์ฅ์ ๋ณ๋ช
} { ๋ธ๋์น๋ช
}
// git pull --rebase = git fetch + git rebase
// pull ๋ช
๋ น์ด๋ฅผ ์คํํ ๋ merge๊ฐ ์๋ rebase ๋ฐฉ์์ผ๋ก ๋ณํฉ์ ํ๋ ค๋ฉด ๋ค์๊ณผ ๊ฐ์ด --rebase ์ต์
์ ์ฃผ๋ฉด ๋ฉ๋๋ค.
// merge ๋ณด๋ค ํ์คํ ๋ฆฌ( log )๊ฐ ๊น๋ํด์ง๋ค๋ ์ฅ์ ๋๋ฌธ์ Git์์๋ ์ต์ ์ฝ๋๋ก ์
๋ฐ์ดํธ ํ ๋ rebase๋ฅผ ์ฌ์ฉํ ๊ฒ์ ๊ถ์ฅํ๊ณ ์์ต๋๋ค.
git pull = git fetch(๋ง์ถ๊ธฐ) + git merge(ํฉ์น๊ธฐ)
โ
1) git fetch
- local์ ์ฐ๊ฒฐ๋ remote repository์ ๋ธ๋์น ๋ชฉ๋ก๊ณผ ๊ทธ ํ์ผ ๋ด์ฉ์ ์ต์ ์ผ๋ก ์ ๋ฐ์ดํธ ํ๋ ๋ช ๋ น์ด์ ๋๋ค.
- local๊ณผ remote์ ์ฑํฌ๋ฅผ ๋ง์ถ๋ ์๋ก๊ณ ์นจ ์ญํ ์ ๋๋ค.
2) git merge
- ๋ ๊ฐ์ branch๋ฅผ ๋ณํฉํ๋ ๋ช ๋ น์ด์ ๋๋ค.
โ- git pull์ ํ์ ๊ณผ์ ์์ ํ๋ก์ ํธ์ ์ต์ ์ฝ๋๋ฅผ local๋ก ๊ฐ์ ธ์ค๋ ์ญํ ๋ก ๋ง์ด ์ฌ์ฉํฉ๋๋ค.
- git clone์ ํ๋ฉด ๋์ ์์ ๊ณผ ๋๋ฃ์ ์์ ํ ์ต์ ๋ฒ์ ์ ๊ฐ๊ฐ ๋ ๋ฆฝ๋ ์กด์ฌ๊ฐ ๋์ด๋ฒ๋ฆฝ๋๋ค. ํ์ง๋ง git pull์ ์ฌ์ฉํ๋ฉด ๋ด๊ฐ ์์ ์ค์ธ local repository์ ์ต์ ์ฝ๋๊ฐ ๋น๊ต๋ฐ ๋ณํฉ๋์ด, ์ต์ ๋ฒ์ ํ์ผ๋ค์ด ๋์ local repository์ ์ ์ฉ๋ฉ๋๋ค. ๋ฐ๋ผ์ ๋ด๊ฐ ์์ ํ๊ณ ์๋ ์ฝ๋๋ค๊ณผ ์ต์ ๋ฒ์ ํ์ผ์ ์ฝ๋๋ ํจ๊ป ์กด์ฌํ๊ฒ ๋์ฃ . ์ฆ, ๋ด๊ฐ ์์ ํ ์ฝ๋์ ๋๋ฃ์ ์์ ์ฝ๋๊ฐ ์๋์ผ๋ก ํฉ์ณ์ง๊ฒ ๋๋๊น ๋งค์ฐ ๋ฐ๋์งํฉ๋๋ค.
โ
โ
โ
โ
โ
'๐ DevOps > ๐ฅ GIT' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| GIT ์๊ฒฉ ์ ์ฅ์ ๋ช ๋ น์ด: branch, merge, checkout, push (0) | 2021.10.13 |
|---|---|
| [GIT] ๋ค๋ฅธ ์์ด๋ ์ฌ์ฉ์, "remote: Permission to ์๋ฌ" (์๋์ฐ) (0) | 2021.02.14 |
| [GIT] ์์ฃผ ๋ฐ์ํ๋ ERROR ๋ชจ์ (0) | 2021.01.28 |
| [GIT] ์์ฃผ์ฐ๋ ๊ธฐ๋ณธ์ ์ธ git ๋ช ๋ น์ด ๋ชจ์ (0) | 2021.01.26 |
| [GIT] ์ ๋ฌธ, ๊ตฌ์กฐ, ์๋ ์์์ ๋ํด ์์๋ณด์ (0) | 2021.01.26 |