GIT
GIT copied to clipboard
๐ GIT ์ฌ์ฉ๋ฒ์ ๋ฐฐ์ ๋ด ์๋ค ๐ฅ
๐GIT ์ฌ์ฉ๋ฒ๐ฐ

Contents
- GIT์ ์ฌ์ฉํ๊ธฐ ์ํ ์ค๋น๐พ
git --version
- GIT ์ค์ ํ๊ธฐ๐
git config --global user.name "์ด๋ฆ"git config --global user.email "์ด๋ฉ์ผ"git config --global --edit"git config --global core.autocrlf input(Mac)git config --global core.autocrlf true(Window)git config --global core.editor "xed --wait"(Xcode)git config --global core.editor "code --wait"(Visual Studio Code)
- GIT ์์ฑํ๊ณ ์ญ์ ํ๊ธฐ๐
git initrm -rf .git
- Working Directory์์ ํ์ผ Track ๋๋ Untrack ํ๊ธฐ๐โจ
git add ํ์ผ๋ชgit add .
git rm --cached ํ์ผ๋ชecho ํ์ผ๋ช > .gitignoreecho *.log > .gitignore
git statusgit status -s
- Staging Area์์ Track๋ ํ์ผ์ ๋ณ๊ฒฝ์ฌํญ ํ์ธํ๊ธฐ๐
git diffgit diff --staged
git difftool[diff] tool = vscode[difftool "vscode"] cmd = code --wait --diff $LOCAL $REMOTE
- Commitํ์ฌ GIT์ ์ ์ฅํ๊ณ , ๋ถ๋ฌ์ค๊ธฐ๐ฅ๐ค
git commit -m "์ปค๋ฐ ๋ฉ์์ง"git loggit log --oneline --graph --all
git checkout ํด์์ฝ๋
- Alias๋ฅผ ์ด์ฉํ์ฌ ๋๋ง์ ๋จ์ถ ๋ช
๋ น์ด๋ฅผ ์ฌ์ฉํ์โ
git config --global alias.๋ช ๋ น์ด "๋จ์ถํ ๋ช ๋ น์ด"git log --pretty=๋ช ๋ น์ด
- Log๋ฅผ ์ด์ฉํด ํ์คํ ๋ฆฌ ์กฐํํ๊ธฐ(์ฌํ)๐
git log ๋ช ๋ น์ดgit log -์ซ์git log --before="๋ ์ง"git log --author="์ด๋ฆ"git log --grep="์ปค๋ฐ ๋ฉ์์ง"git log -S "ํ์ผ๋ช "
- [Control-Z] ๋๋๋ฆฌ๊ธฐโฉ
git commit --amendgit restore -- ํ์ผ๋ช
- Tag๋ฅผ ์ด์ฉํด ๊ฐ๋จํ๊ฒ ๋ฒ์ ํ์ํ๊ธฐโ
git taggit tag -l ํ๊ทธ๋ชgit tag -d ํ๊ทธ๋ช
git tag ํ๊ทธ๋ชgit tag ํ๊ทธ๋ช ํด์์ฝ๋ -a -m "ํ๊ทธ ๋ฉ์์ง"
git show ํด์์ฝ๋git show head --name-only
- Branch๋ฅผ ์ด์ฉํด ๋
๋ฆฝ๋ ๊ณต๊ฐ์์ ๋๋ง์ ์์
๊ณต๊ฐ์ ๋ง๋ค์๐
git branchgit branch -vgit branch -allgit branch --mergedgit branch --no-merged
git branch ๋ธ๋์น๋ชgit switch -C ๋ธ๋์น๋ช
git branch --move ๋ธ๋์น๋ช ๋ฐ๊ฟ๋ธ๋์น๋ชgit branch -d ๋ธ๋์น๋ช
- Merge! ํ๋์ Branch๋ก ๋ณํฉํ๊ธฐ๐
git merge ๋ธ๋์น๋ชgit merge --no-ff
- Merge Conflict์ Merge Tool๐งท
git merge --abortgit merge --continuegit mergetool[merge] tool = vscode[mergetool "vscode"] cmd = code --wait $MERGED
- Rebase์ Cherry-Pick๐
git rebase ๋ธ๋์น๋ชgit rebase ๋ธ๋์น๋ช ๋ธ๋์น๋ชgit rebase --onto ๋ธ๋์น๋ช ๋ธ๋์น๋ช ๋ธ๋์น๋ชgit rebase --abortgit rebase --continue
git cherry-pick ํด์์ฝ๋
- GIT ๋๊ตฌ - Stash, Cleanโ
git stash push -m "์คํ์ ๋ฉ์์ง"git stashgit stash -ugit stash --keep-index
git stash listgit stash show ์คํ์git stash show ์คํ์ --patch
git stach apply ์คํ์git stash pop ์คํ์
git stash drop ์คํ์git stash clear
git stash branch ๋ธ๋์น๋ชgit cleangit clean -fdgit clean -xgit clean -d -n
- Reset์ผ๋ก ๋๋์๊ฐ๊ธฐโฎ
git resetgit reset --soft ํด์์ฝ๋git reset --hard ํด์์ฝ๋
git restore --source=ํด์์ฝ๋ ํ์ผ๋ชgit revert ํด์์ฝ๋
- GIT ๋๊ตฌ - RefLog๐
git refloggit reflog expire --expire=์๊ฐ --all
git show HEAD@{์ซ์}git show ๋ธ๋์น๋ช @{์๊ฐ}
- Rebase -i ์ต์
์ผ๋ก Commit ์์ ํ๊ธฐโ
git rebase -igit rebase --abortgit rebase --continue
- GIT ๋๊ตฌ - GIT์ผ๋ก ๋ฒ๊ทธ์ฐพ๊ธฐ(Blame, Bisect)๐
git blame ํ์ผ๋ชgit blame -C -L ์ซ์,์ซ์ ํ์ผ๋ช
git bisect startgit bisect goodgit bisect bad
- GitHub - Remote ์ ์ฅ์ ํ์ฉํ๊ธฐโ
git remotegit remote -vgit remote add origin ์ฃผ์git remote remove ์ฃผ์
git clone ์ฃผ์git pushgit pullgit fetch
- ์๋๋ฆฌ์ค - Pull request
- Git๊ณผ Terminal ์ปค์คํ
์ธํ
โ๏ธ
git config --global