๐ ๏ธ Git ์ด๊ธฐ ์ค์
Git์ ์ค์นํ๊ณ ๋๋ฉด Git์ ์ฌ์ฉ ํ๊ฒฝ์ ์ ์ ํ๊ฒ ์ค์ ํด ์ฃผ์ด์ผ ํฉ๋๋ค.
ํ๊ฒฝ ์ค์ ์ ํ ์ปดํจํฐ์์ ํ ๋ฒ๋ง ํ๋ฉด ๋๊ณ ์ค์ ํ ๋ด์ฉ์ Git์ ์ ๊ทธ๋ ์ด๋ํด๋ ์ ์ง๋ฉ๋๋ค.
# Git ์ฌ์ฉ์ ID
git config --global user.name "seulbinim"
# Git ์ฌ์ฉ์ Email
git config --global user.email seulbinim@gmail.com
# Git Default Editor ์ค์ (Visual Studio Code)
git config --global core.editor "code --wait"
# windows์ Mac OS์ ๊ณต๋ฐฑ๋ฌธ์(์ค๋ฐ๊ฟ) (Carriage return, Lind Feed)
# Windows ํ๊ฒฝ
git config --global core.autocrlf true
# Mac OS ํ๊ฒฝ
git config --global core.autocrlf input
๋ํ ์ธ์ ๋ ์ง ์ค์ ๊ฐ์ 'git config’๋ผ๋ ๋๊ตฌ๋ก ํ์ธํ๊ณ ๋ณ๊ฒฝํ ์ ์์ต๋๋ค.
# Git Confing ์ค์ ํ์ธํ๊ธฐ
# ํฐ๋ฏธ๋์์ ํ์ธ
git config --list
# ๊ธฐ๋ณธ ์๋ํฐ์์ ํ์ธ
git config --global -e
Git์ด ๊ด๋ฆฌํ๋ ์ ์ฅ์์ ๊ธฐ๋ณธ ๋ธ๋์น๊ฐ master์ผ ๊ฒฝ์ฐ main์ผ๋ก ๋ณ๊ฒฝํ ์ ์์ต๋๋ค.
๐ธ Git Command
git init : ์ ์ฅ์ ์์ฑ
# ํ์ฌ ๋๋ ํ ๋ฆฌ๋ฅผ Git ์ ์ฅ์๋ก ์์ฑ
# .git ํด๋(์จ๊น ํด๋)๊ฐ ์์ฑ๋จ
git init
git status : ํ์ฌ ์ํ ํ์ธ
git status
# ๋ณ๊ฒฝ๋ ํ์ผ๋ช
์ด ๋นจ๊ฐ์์ผ๋ก ๋ณด์ผ ๊ฒฝ์ฐ Working Directory ์ํ
# ๋ณ๊ฒฝ๋ ํ์ผ๋ช
์ด ์ด๋ก์์ผ๋ก ๋ณด์ผ ๊ฒฝ์ฐ Staging Area ์ํ
# nothing to commit, working tree clean์ ๊ฒฝ์ฐ ๋ณ๊ฒฝ ๋ด์ฉ์ด ์์์ ๋ํ๋
git difftool : ํ์ผ์ ๋ณ๊ฒฝ๋ด์ฉ ๋น๊ตํ๊ธฐ
# difftool์ ์ฌ์ฉํ์ฌ ํ์ผ์ ๋ณ๊ฒฝ๋ด์ฉ์ ๋น๊ต
git config --global -e
[diff]
tool = vscode
[difftool "vscode"]
cmd = code --wait --diff $LOCAL $REMOTE
git difftool
git add : ํ์ผ์ ๋ณ๊ฒฝ ์ฌํญ์ index(Staging Area)์ ์ถ๊ฐ
# ํน์ ํ์ผ์ Staging Area์ ์ถ๊ฐํ๊ธฐ
git add <file>
# ๋ณ๊ฒฝ ๋ด์ฉ์ด ์๋ ๋ชจ๋ ํ์ผ์ Staging Area์ ์ถ๊ฐํ๊ธฐ
git add *
git add .
git restore <file> : ์์ ๋ด์ฉ ์ทจ์
# Working Directory์ ๋ณ๊ฒฝ ๋ด์ฉ์ ์ทจ์ํ ๊ฒฝ์ฐ(Tracked File)
git restore <file>
# Staging Area์ ๋ณ๊ฒฝ ๋ด์ฉ์ Working Directory๋ก ๋๋๋ฆด ๊ฒฝ์ฐ
git restore --staged <file>