์ ๋ก๋ํ๋ ๋ฐฉ๋ฒ
- ๊นํ๋ธ ๊ฐ์
- GitBash ์ค์น (์๋์ฐ)
- ๋ฃจํธ ํด๋๋ฅผ ๋ง๋ค๊ณ – ์ฐํด๋ฆญ – Git Bash Here
- -ํ ์คํธํ์ผ์ ๋ฃจํธํด๋ ์๋์ ์์ฑ-
- git init
- git remote add origin "repository address"
์) git remote add origin https://github.com/vo0a/vo0a_gitTest - git status (์ํํ์ธ)
- git add . (๋ณ๊ฒฝ๋ ํ์ผ์ ๋ชจ๋ Tracking)
- git config –global user.email "email address"
- git config –global user.name “name”
-.git ์จ๊น์ฒ๋ฆฌ๋์ด์๊ณ
์ต๊ทผ Git์ด ์ ๋ฐ์ดํธ๋๋ฉด์ ๋งจ์ฒ์ global ์ด๊ธฐ๊ฐ์ ์๊ตฌ- - git commit -m "message" (์ธ์)
- git push origin +master
๋ก๊ทธ์ธ์ ํด์ค๋ค.
9๋ฒ๊ณผ 10๋ฒ์ git์ ์ค์นํ ์ดํ ๋ฑ ํ ๋ฒ๋ง ์ค์ ํด ๋๋ฉด ๋๋ค.
11๋ฒ์๋ ์ด๋ฒ ์ปค๋ฐ๊ณผ ๊ด๋ จ๋ ๋ด์ฉ์ ๊ฐ๋ตํ ์ค๋ช ํด ๋๋ค.
๋ค๋ฅธ ์ฌ๋์ git ๊ฐ์ ธ์ค๊ธฐ
- ๋ก์ปฌ์์ ์๋ก์ด ํด๋ ์์ฑ - ์ฐํด๋ฆญ - Git Bash Here
- git init
- git remote add origin "address"
- git pull origin master
git init ๊ณผ git remote add origin adress๋ ํด๋์ ํ ๋ฒ๋ง ์ ์ฉํ๋ค.
push ์ ์ pull์ด ์๋ค.
์ฌ๋ฌ๋ช ์ด ํ๋์ github๋ฅผ ์ฌ์ฉํ ๋ ํญ์ pull์ ๋จผ์ ํ์.
๊ทธ๋ ์ง ์์ ๊ฒฝ์ฐ ๋ฎ์ด์ธ ์ํ์ด ์๋ค.
BRANCH ์์ฑํ๊ธฐ
local์์ feature-01์ด๋ผ๋ branch๋ฅผ ์์ฑํ๊ณ ์ถ์๋๋, ๋ค์๊ณผ ๊ฐ์ command๋ฅผ ํตํด์ feature-01 branch๋ฅผ ์์ฑํ ์ ์์ต๋๋ค.
git checkout -b feature-01
๋ง์ฝ, ํด๋น branch๋ฅผ ์ ์ฅ์ remote branch์๋ ์์ฑํ๊ณ ์ถ์๋๋, ๋ค์๊ณผ ๊ฐ์ command๋ฅผ ์ฌ์ฉํฉ๋๋ค.
git push origin feature-01
์ด๋ ๊ฒ๋๋ฉด local๊ณผ ์ ์ฅ์์ remote branch๊ฐ ์์ฑ๋ฉ๋๋ค.
์์ฑ๋ branch๋ ๊ฐ์๊ฐ local ๋ฐ ์ ์ฅ์ ๊ธฐ์ค์ด๋ฏ๋ก, local์ branch๋ฅผ retmoe branch์ ์ฐ๋ํ๋ ์์
์ ์ํํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
branch ์ฐ๋์ ๋ค์์ ํตํด ์ํํฉ๋๋ค.
git branch --set-upstream-to origin/feature-01
BRANCH ์ญ์ ํ๊ธฐ
์์
์ด ๋๋๊ณ , ๊ธฐ์ค branch๋ก pull request๊ฐ ์ข
๋ฃ๋์ด์ merge๊น์ง ์๋ฃ ๋์๋ค๋ฉด, ํด๋น branch๋ฅผ ์ญ์ ํด์ค๋๋ค.
merge ์์
์ด ๋๋ local์ feature-01 branch๋ฅผ ์ญ์ ํ๊ธฐ ์ํด์๋, ๋ค๋ฅธ branch๋ก checkout ํ, feature-01 branch๋ฅผ ์ญ์ ํด ์ฃผ์ด์ผ ํฉ๋๋ค.
์ฌ๊ธฐ์๋ develop branch๋ก ์ด๋ํด์ feature-01 branch๋ฅผ ์ญ์ ํด ๋ณด๊ฒ ์ต๋๋ค.
git checkout develop
git branch --delete feature-01
๊ทธ๋ฌ๋, ์์
๋ ์ฌํญ์ด๋ commit ํ ์ด๋ ฅ์ด ๋จ์์๋ ๊ฒฝ์ฐ, ํด๋น command๋ก branch๊ฐ ์ญ์ ๋์ง ์๋ ๊ฒฝ์ฐ๊ฐ ์์ต๋๋ค.
์ด๋ฌํ ๊ฒฝ์ฐ์๋ ๊ฐ์ ๋ก branch๋ฅผ ์ญ์ ํ ์ ์์ต๋๋ค.
git branch -D feature-01
-D(๋๋ฌธ์) option์ ํตํด์ local branch๋ฅผ ๊ฐ์ ๋ก ์ญ์ ํ ์ ์์ต๋๋ค.
์ด ๊ฒฝ์ฐ, local์ branch๋ ์ญ์ ๋์์ผ๋, remote branch๋ ์ญ์ ๊ฐ ์์ง ๋์ง ์์์ต๋๋ค. remote branch๋ฅผ ์ญ์ ํ๊ธฐ ์ํด์๋, ๋ค์๊ณผ ๊ฐ์ command๋ฅผ ์ํํฉ๋๋ค.
git push origin :feature-01
ํด๋น command๋ฅผ ํตํด์ ์๊ฒฉ remote branch๋ฅผ ์ญ์ ํ ์ ์์ต๋๋ค.
git commit message ๋ณ๊ฒฝํ๊ธฐ
- git log
commit ๋ชฉ๋ก ํ์ธ - git commit --amend
git push ์ทจ์ํ๊ธฐ
- git reset HEAD^ ๋๋ git reset HEAd .
- ์ถ์ฒ
'๐ > GIT' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Git] ๋ด๊ฐ ๋ณด๊ธฐ ์ํด ์ ๋ฆฌํ๋ Git 2 (0) | 2020.04.23 |
---|
๋๊ธ