보통 git을 설치하고 처음 configuration을 조작하는 경우는 push하는 경우일 것입니다. 다음과 같이 누구인지 자신의 정보를 기록하라는 메시지를 만납니다.
git config 파일은 3개가 있습니다.
- /etc/gitconfig 파일, 윈도우즈에서는
C:\ProgramData\Git\config
- ~/.gitconfig, ~/.config/git/config 파일, 윈도우즈에서는
C:\Users\$USER\.gitconfig
- .git/config 파일
git config example1
git config –global user.email “crowdy@gmail.com”
git config –global user.name “crowdy kim”
.gitconfig 파일에 설정이 저장됩니다.
각 설정은 역순으로 우선시 된다. 그래서 .git/config 가 /etc/gitconfig 보다 우선합니다.
그러면, 이 파일의 내용을 아예 한 번에 싹 복사해 보리면 어떨까요
.gitconfig 파일 열기
두 가지 방법이 있습니다. powershell로 여는 방법과 디폴트 에디터로 여는 방법
- code $Env:USERPROFILE.gitconfig
- git config –global -e
그런데, 디폴트 에디터는 vim입니다. VSCode가 설치되어 있어, 이를 사용하고 싶다면 다음과 같은 명령을 사용하여 에디터를 변경해 둘 수도 있습니다.
git config --global core.editor "code"
[credential]
helper = manager
[credential "helperselector"]
selected = manager
[alias]
adog = log --all --decorate --oneline --graph
hist = log --graph --date-order --date=short --pretty=format:'%C(auto)%h%d %C(reset)%s %C(bold blue)%ce %C(reset)%C(green)%cr (%cd)'
graph = log --graph --date-order -C -M --pretty=format:'<%h> %ad [%an] %Cgreen%d%Creset %s' --all --date=short
lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = !'git lg1'
[core]
quotePath = false
[user]
email = crowdytkim@gmail.com
name = crowdy kim
git 설정 확인하기
만약 전체 config 리스트를 볼 때는 다음의 명령을 사용합니다.
git config --list
git config 삭제하기
설정 항목을 삭제할 때는 unset
을 사용합니다.
git config --unset user.email