์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
- Git๋ช ๋ น์ด
- ![rejected]
- branch ์ญ์
- branch ์์ฑ
- ๋ธ๋์น ํ์ธ
- ์ฝ๋๋ธ๋ก
- ๋งํฌ๋ค์ด
- markdown
- branch ํ์ธ
- ์ฝ๋๋ธ๋ญ
- ๋ธ๋์น ์ญ์
- ๋ธ๋์น ์์ฑ
- Today
- Total
DevLog
Git cli๋ช ๋ น์ด ์ ๋ฆฌ ๋ณธ๋ฌธ
๊ธฐ๋ณธ ๋ช ๋ น์ด
Remote Repository์ ์๋ ํ์ผ์ Local Repository๋ก ๋ณต์ฌ
git clone <๋ ํ์งํ ๋ฆฌ ์ฃผ์>
๋ด Local Repository์ staging area, untracked files ๋ชฉ๋ก์ ํ์ธ
ex) ๋๋ฃ์ ํ์
ํ ๋ ์๋ ๋ณํฉ(merge)์คํจ ์ ์ด๋ค ํ์ผ์ด ์ถฉ๋ํ๊ณ ์๋์ง ํ์ธgit status
commit ๋์ง ์์ Local Repository ์ ๋ณ๊ฒฝ์ฌํญ์ ํ๊ธฐ(discard changes)
git restore <ํ์ผ๋ช
>
๋ด Local Repository์ untracked file์ Git์ ๊ด๋ฆฌ ํ์ธ staging area๋ก ์ถ๊ฐ์์ผ ํ์ผ์ commit ํ ์ ์๋ ์ํ๋ก ๋ง๋ค๊ธฐ
git add <ํ์ผ๋ช
>
Staging area์ ๋ชจ๋ ํ์ผ์ ํ๋ฒ์ ์ถ๊ฐ
git add .
์์ ์์ ์ด ๋๋ฌ์ ๋ ๋ณ๊ฒฝ ์ฌํญ์ ์ ์ฅ, -m ์ต์ ์ ํตํด ์ปค๋ฐํ ๋ด์ฉ์ ์ฝ๋ฉํธ๋ฅผ ์์ฑ
git commit -m '์ปค๋ฐ ๋ฉ์์ง'
Local ์์ commit ํ ๋ด์ฉ์ ์ทจ์ํ ๋ ๊ฐ์ฅ ์ต์ ์ commit ์ ์ทจ์
git reset HEAD^
Local ์์ ๋ณ๊ฒฝ, commit ๋ ์ฌํญ์ Remote Repository์ ์ ๋ก๋
git push <origin> <branch>
ํ์ฌ๊น์ง commit ๋ ๋ด์ญ๋ค์ ํฐ๋ฏธ๋ ์ฐฝ์์ ํ์ธ(q๋ก ํฐ๋ฏธ๋ ์ฐฝ์ ์ข ๋ฃ)
git log
๊ธฐ์กด ๋๋ ํ ๋ฆฌ๋ฅผ Git Repository๋ก ๋ณํํ๊ฑฐ๋ ์๋ก์ด Repository๋ฅผ ์ด๊ธฐํ
git init
๋์ Local Repository์ ๋์ Remote Repository ์ฐ๊ฒฐ
git remote add <origin> <Repository ์ฃผ์>
๋์ Local Repository์ pair์ Remote Repository ์ฐ๊ฒฐ
git remote add <pair> <Repository ์ฃผ์>
ํ์ฌ์ Local Repository์ ์ฐ๊ฒฐ๋ ๋ชจ๋ Remote Repository ๋ชฉ๋ก ํ์ธ
git remote -v
pair Remote Repository์ ํด๋น branch ๋ด์ฉ์ Local Repository๋ก ๊ฐ์ ธ์ค๊ธฐ
git pull <pair> <branch>
๋ธ๋์น ๋ช ๋ น์ด ๋ชจ์
์๋ก์ด ๋ธ๋์น ์์ฑ
git branch ์๋ก์ด ๋ธ๋์น ์ด๋ฆ
์๋ก์ด ๋ธ๋์น ์์ฑ ํ ํด๋น ๋ธ๋์น๋ก ์ ํ
git switch -c ์๋ก์ด ๋ธ๋์น ์ด๋ฆ
git checkout -b ์๋ก์ด ๋ธ๋์น ์ด๋ฆ
๋ธ๋์น ๋ชฉ๋ก ํ์ธ
git branch
๋ธ๋์น ๋ชฉ๋ก๊ณผ ๊ฐ ๋ธ๋์น์ ์ต๊ทผ ์ปค๋ฐ ํ์ธ
git branch -v
๋ธ๋์น ์ญ์
git branch -d ์ญ์ ํ ๋ธ๋์น ์ด๋ฆ
git branch -D
ํด๋น ๋ช
๋ น์ด๋ ๋ณํฉํ์ง ์์ ๋ธ๋์น๋ฅผ ๊ฐ์ ์ญ์ ํ๋ ๋ฐฉ๋ฒ์
๋๋ค.
๋ธ๋์น ์ ํ
git switch ๋ธ๋์น ์ด๋ฆ
git checkout ๋ธ๋์น ์ด๋ฆ
๋ธ๋์น ๋ณํฉ
- master ๋ธ๋์น๋ก dev ๋ธ๋์น๋ฅผ ๋ณํฉํ ๋ (master โ dev)
1.git checkout master
2.git merge dev
๋ก๊ทธ์ ๋ชจ๋ ๋ธ๋์น๋ฅผ ๊ทธ๋ํ๋ก ํํ
git log --branches --graph --decorate
์์ง commit ํ์ง ์์ ์์ ์ ์คํ์ ์์๋ก ์ ์ฅ
git stash
๊ธฐํ ๋ช ๋ น์ด
Git ์ ์ฅ์ ์ฃผ์ repository ๋ณ๊ฒฝํ๊ธฐ
git remote set-url <origin> <์๋ก์ด Git URL>
Git init์ ์ทจ์ํ๋ ๋ช
๋ น์ด, .git
ํด๋๊ฐ ์ญ์ ๋๋ฉฐ Git ๋ก์ปฌ ์ ์ฅ์ ์ง์ ์ ํด์
rm -rf .git
'๐ง๐ปโ๐ป ๊ฐ๋ฐ๊ฐ๋ฐ > Git' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
git init ์ทจ์ํ๊ธฐ (0) | 2021.06.29 |
---|---|
Git branch ํ์ธ, ์์ฑ ๋ฐ ์ญ์ / ๋ก์ปฌ ์ ์ฅ์ default branch ๋ณ๊ฒฝํ๊ธฐ (0) | 2021.06.29 |