
1. ๋ธ๋์น ์์ฑ
- ๋ธ๋์น๋ ๋ ๋ฆฝ์ ์ผ๋ก ์ด๋ค ์์ ์ ์งํํ๊ธฐ ์ํ ๊ฐ๋ ์ผ๋ก ๊ฐ๊ฐ์ ๋ธ๋์น๋ ๋ค๋ฅธ ๋ธ๋์น์ ๋ ๋ฆฝ์ ์ด๋ค.
- ๋ฉ์ธ ๋ธ๋์น: ๋ฐฐํฌํ ์ ์๋ ์์ค์ ์์ ์ ์ธ ๋ธ๋์น
- ํ ํฝ ๋ธ๋์น: ๊ธฐ๋ฅ ์ถ๊ฐ๋ ๋ฒ๊ทธ ์์ ๊ณผ ๊ฐ์ ๋จ์ ์์
์ ์ํ ๋ธ๋์น
$ git branch
# ๋ธ๋์น ๋ชฉ๋ก ํ์ธ
$ git checkout ๋ธ๋์น์ด๋ฆ
# ๋ธ๋์น ์ ํ
$ git checkout snapshot hash code
# ์ค๋
์ท ์ด๋๋ ๊ฐ๋ฅ
$ git branch ๋ธ๋์น์ด๋ฆ
# ๋ธ๋์น ์์ฑ
2. ๋ธ๋์น ๋ณํฉ
$ git checkout master
$ git merge topic_branch
$ git branch --merged
# merge๋ branch ํ์ธ
$ git branch -d branch name
# ์ฌ์ฉ์ ๋ง์น ๋ธ๋์น๋ฅผ ์ญ์ ํ๋ค.
# delete the branch only if it has already been pushed and merged with the remote branch.
$ git branch -D ๋ธ๋์น๋ช
# push, merge ์ฌ๋ถ์ ์๊ด์์ด ๋ธ๋์น๋ฅผ ์ญ์ ํ๋ค.
# if you want to force the branch to be deleted, even if it hasn't been pushed or merged yet.
- fast-forward ๋ณํฉ: ๋ง์คํฐ ๋ธ๋์น์์ ๋ณ๊ฒฝ์์ด ์๋ก์ด ๋ด์ฉ๋ง ์ถ๊ฐ๋๋ ๊ฒ
- git merge confict: mergeํ ๋ ๋ธ๋์น์์ ๊ฐ์ ํ์ผ์ ๋ณ๊ฒฝํ์ ๋ ์ถฉ๋์ด ๋ฐ์ํ๋ค.
3. ์๊ฒฉ ์ ์ฅ์์์ ๊ฐ์ ธ์ค๊ธฐ
$ git remote add origin ์ฃผ์
# ์๊ฒฉ์ ์ฅ์์์ ์ฐ๊ฒฐ
$ git remote rename origin ๋ค๋ฅธ์ด๋ฆ
# ์๊ฒฉ์ ์ฅ์์ ์ด๋ฆ์ด: origin -> ๋ค๋ฆ์ด๋ฆ ์ผ๋ก ๋ฐ๋๋ค.
$ git remote rm origin
# ์ฃผ์๊ฐ ๋ณ๊ฒฝ๋์๊ฑฐ๋ ํ์์์ด์ง ์ ์ฅ์ ์ญ์
$ git remote -v
# ์ง์ ํ ์ ์ฅ์์ ์ด๋ฆ๊ณผ ์ฃผ์๋ฅผ ํจ๊ป ๋ณผ ์ ์๋ค
$ git pull
# ์๊ฒฉ์ ์ฅ์์์ ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ + ๋ณํฉ
$ git fetch
# ์๊ฒฉ์ ์ฅ์์์ ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ
# fetch ํ์๋ git merge๋ฅผ ํตํด ๋ฐ๋ก ๋จธ์ง๋ฅผ ์์ผ์ค์ผํ๋ค.
- ์๊ฒฉ์ ์ฅ์์ ์ด๋ฆ์ origin์ด default์ด๊ธฐ ๋๋ฌธ์ clone์ผ๋ก ๋ณต์ฌํด์จ ์ ์ฅ์์ ์ด๋ฆ์ origin์ผ๋ก ํต์ผ๋๋ค.
- git clone์ ํ์ผ๋ง ๋ฐ์์ค๋ ๊ฒ์ด๊ธฐ ๋๋ฌธ์ ์๊ฒฉ์ ์ฅ์์ ์ฐ๊ฒฐํ๋ ค๋ฉด git remote add orign์ ํตํด ์ฐ๊ฒฐ์์ผ์ฃผ๋ ์์ ์ด ํ์ํ๋ค.
'๐ DevOps > ๐ฅ GIT' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| GIT double dash์ ์๋ฏธ: git checkout -- filename (0) | 2022.01.15 |
|---|---|
| GIT ๋ผ์ดํ์ฌ์ดํด: git ๊ด๋ฆฌ์ํ ํ์ธ: status, log (0) | 2022.01.15 |
| [GIT] ๋ค๋ฅธ ์์ด๋ ์ฌ์ฉ์, "remote: Permission to ์๋ฌ" (์๋์ฐ) (0) | 2021.02.14 |
| [GIT] ์์ฃผ ๋ฐ์ํ๋ ERROR ๋ชจ์ (0) | 2021.01.28 |
| ์๋ก์ด ๋ก์ปฌํ๊ฒฝ์์ ์์ ํ ๊ฒฝ์ฐ (0) | 2021.01.26 |