본문으로 건너뛰기

Git config

git config

git config <flag> <key> <value>
  • <flag>
    • --system: 시스템 설정(/etc/gitconfig)
    • --global: 유저 설정(~/.gitconfig)
    • --local: 프로젝트 설정(.git/config)

url 설정

insteadOf로 url 값 변환

git config url.<newURL>.insteadOf <oldURL>

clone, fetch, push 등을 수행할 때, 입력한 URL이나 설정한 URL 중 <oldURL>로 시작하는 URL이 있다면 <newURL>로 변환한 후 명령을 수행합니다.

예를 들어 특정 프로그램이 git으로 https:/github.com 경로의 리포지토리에 접근할 때, 해당 프로그램 수정 없이 https 대신 ssh를 사용하도록 설정하고 싶다면 아래와 같은 명령어를 사용하면 됩니다.

git config --global url.ssh://[email protected]/.insteadOf https://github.com/

Signing 설정

SSH signing

git config --global gpg.format ssh
git config --global user.signingkey <publicKeyPath>
git config --global commit.gpgsign true
git config --global tag.gpgsign true
~/.ssh/allowed_signers
<email>[,<email>] [namespace="<namespace>[,<namespace>]"] <publicKey>
# [email protected] ssh-ed25519 AAAA...
git config --global gpg.ssh.allowedSignersFile ~/.ssh/allowed_signers

기타

  • git config --global branch.sort -committerdate
  • git config --global diff.algorithm histogram
  • git config --global pull.rebase true
  • git config --global push.autoSetupRemote true
  • git config --global push.default simple: 브랜치를 현재 브랜치와 같은 이름의 원격 브랜치를 설정합니다.
  • git config --global rebase.autoStash true
  • git config --global status.submoduleSummary true: submodule을 사용할 때, status에서 submodule 변경사항을 요약해서 보여줍니다.
  • git config --global tag.sort version:refname: tag를 정렬할 때, 버전 순으로 정렬합니다.