# 인기 있는 Git 설정 옵션들

> Clean Markdown view of GeekNews topic #13405. Use the original source for factual precision when an external source URL is present.

## Metadata

- GeekNews HTML: [https://news.hada.io/topic?id=13405](https://news.hada.io/topic?id=13405)
- GeekNews Markdown: [https://news.hada.io/topic/13405.md](https://news.hada.io/topic/13405.md)
- Type: GN+
- Author: [neo](https://news.hada.io/@neo)
- Published: 2024-02-17T18:39:53+09:00
- Updated: 2024-02-17T18:39:53+09:00
- Original source: [jvns.ca](https://jvns.ca/blog/2024/02/16/popular-git-config-options/)
- Points: 59
- Comments: 4

## Topic Body

- `pull.ff only` 또는 `pull.rebase true`  
  - 두 설정 모두 `git pull`을 실행할 때 브랜치가 상위 브랜치와 다를 경우 실수로 병합 커밋을 생성하는 것을 방지하기 위함.  
  - `pull.rebase true`는 매번 `git pull --rebase`를 실행하는 것과 동일.  
  - `pull.ff only`는 매번 `git pull --ff-only`를 실행하는 것과 동일.  
  - 두 설정을 동시에 사용하는 것은 의미가 없으며, `--ff-only`가 `--rebase`를 덮어쓰기 때문.  
  
- `merge.conflictstyle zdiff3`  
  - 병합 충돌을 더 읽기 쉽게 만드는 설정.  
  - `diff3`는 기본 설정에서 병합 충돌을 보여주는 방식을 변경하여 원본 코드를 중간에 표시.  
  - `zdiff3`는 `diff3`의 개선된 버전으로 더 나은 것으로 여겨짐.  
  
- `rebase.autosquash true`  
  - 오래된 커밋을 수정하기 쉽게 만드는 기능.  
  - `git commit --fixup OLD_COMMIT_ID`를 사용하여 커밋하면 `git rebase --autosquash main`을 실행할 때 자동으로 `fixup!` 커밋을 대상과 결합.  
  
- `rebase.autostash true`  
  - `git rebase` 전후로 자동으로 `git stash`와 `git stash pop`을 실행.  
  
- `push.default simple`, `push.default current`  
  - 현재 브랜치를 같은 이름의 원격 브랜치로 자동으로 푸시하도록 설정.  
  - `push.default simple`은 기본 설정으로, 브랜치가 이미 원격 브랜치를 추적하고 있을 때만 작동.  
  - `push.default current`는 항상 로컬 브랜치를 동일한 이름의 원격 브랜치로 푸시.  
  
- `init.defaultBranch main`  
  - 새로운 저장소를 생성할 때 `master` 대신 `main` 브랜치를 생성.  
  
- `commit.verbose true`  
  - 커밋 메시지를 작성하는 텍스트 편집기에 전체 커밋 차이를 추가하여 작업 내용을 기억하는 데 도움.  
  
- `rerere.enabled true`  
  - `git rebase` 중에 병합 충돌을 어떻게 해결했는지 기억하고 자동으로 충돌을 해결.  
  
- `help.autocorrect 10`  
  - git의 자동 수정 기능은 오타를 확인하지만 수정된 명령어를 자동으로 실행하지 않음.  
  - 자동으로 실행하도록 설정하려면 `help.autocorrect`를 `1`, `10`, `immediate`, 또는 `prompt`로 설정.  
  
- `core.pager delta`  
  - `git diff`, `git log`, `git show` 등의 출력을 표시하는 데 사용되는 "pager".  
  - `delta`는 구문 강조 기능이 있는 고급 diff 보기 도구로 설정.  
  
- `diff.algorithm histogram`  
  - 기본 diff 알고리즘은 함수의 순서가 변경될 때 종종 문제를 일으킴.  
  - `diff.algorithm histogram`은 이를 더 명확하게 표시.  
  
- `core.excludesfile`: 전역 .gitignore  
  - 모든 저장소에 적용되는 전역 gitignore 파일 설정.  
  
- `includeIf`: 개인 및 업무용 별도의 git 설정  
  - 개인 및 업무용 저장소에 대해 다른 이메일 주소를 구성하는 데 사용.  
  
- `url."git@github.com:".insteadOf 'https://github.com/'`  
  - `https://github.com`을 `git@github.com:`으로 자동으로 대체.  
  
- `fsckobjects`: 데이터 손상 방지  
  - 데이터 손상을 적극적으로 감지하여 팀을 몇 번 구한 설정.  
  
- submodule 관련 설정  
  - `status.submoduleSummary true`  
  - `diff.submodule log`  
  - `submodule.recurse true`  
  
- 그 외의 설정들  
  - `blame.ignoreRevsFile .git-blame-ignore-revs`  
  - `branch.sort -committerdate`  
  - `color.ui false`  
  - `commit.cleanup scissors`  
  - `core.autocrlf false`  
  - `core.editor emacs`  
  - `credential.helper osxkeychain`  
  - `diff.tool difftastic`  
  - `diff.colorMoved default`  
  - `diff.colorMovedWS allow-indentation-change`  
  - `diff.context 10`  
  - `fetch.prune true` 및 `fetch.prunetags`  
  - `gpg.format ssh`  
  - `log.date iso`  
  - `merge.keepbackup false`  
  - `merge.tool meld`  
  - `push.followtags true`  
  - `rebase.missingCommitsCheck error`  
  - `rebase.updateRefs true`  
  
- 설정 방법  
  - 일반적으로 `git config --global NAME VALUE`를 사용하여 설정.  
  - 옵션을 삭제하려면 `~/.gitconfig`를 수동으로 편집.  
  
- 이 글을 쓴 후 변경한 설정  
  - `diff.algorithm histogram`  
  - `branch.sort -committerdate`  
  - `merge.conflictstyle zdiff3`  
  
- 마무리  
  - 많은 사람들에게 좋아하는 설정을 물어보고 가장 많이 언급된 것들을 나열하는 것이 유용함.  
  
#### GN⁺의 의견  
- 이 글에서 가장 중요한 것은 개발자들이 자주 사용하는 git 설정 옵션들을 알 수 있다는 점임.  
- git을 사용하는 초급 소프트웨어 엔지니어에게 이러한 설정들은 작업 효율성을 높이고 일상적인 문제를 해결하는 데 도움이 될 수 있음.  
- 특히 `merge.conflictstyle zdiff3`나 `rebase.autosquash true` 같은 설정은 병합 충돌 해결과 커밋 히스토리 관리를 더 쉽게 만들어 줌으로써, 협업 과정에서 발생할 수 있는 문제들을 줄일 수 있음.

## Comments



### Comment 23262

- Author: pril1
- Created: 2024-02-23T11:47:56+09:00
- Points: 1

옵션을 삭제하려면 git config --global --unset NAME 커맨드를 사용하는 방법도 있어요

### Comment 23215

- Author: rumbarum
- Created: 2024-02-21T14:46:59+09:00
- Points: 1

본인 설정을 확인하시려면   
  
git config --list 를 추가하세요.

### Comment 23132

- Author: pmc7777
- Created: 2024-02-18T10:21:11+09:00
- Points: 1

메인 개발 환경에선 설정 해놓고 다른 환경에서 설정이 되어있지 않아 왜 안되나.. 했던 경험이 있습니다ㅋㅋㅋ 개발자라면 깃을 매일 사용하는 만큼 깃 설정과 관련된 것들에 대해 관심도가 높아졌으면 좋겠어요

### Comment 23121

- Author: neo
- Created: 2024-02-17T18:39:53+09:00
- Points: 1

###### [Hacker News 의견](https://news.ycombinator.com/item?id=39400352) 
- `core.autocrlf`와 `safecrlf` 설정
  - CRLF 파일 커밋 방지 및 LF로 변환 강제
  - 필요시 `gitattributes`로 오버라이드 가능
- `.gitconfig`의 `alias` 설정
  - 커밋 히스토리를 간결한 그래프로 출력하는 별칭 설정
  - Stack Overflow 게시물에서 가져온 설정
- `rebase.autosquash`와 `fixup` 별칭
  - 자주 사용되는 설정으로, 커밋 후 리베이스 자동화
  - `pull.rebase`도 중요하지만 `fixup` 사용 빈도가 더 높음
- `insteadOf` 설정의 유용성
  - GitHub 리모트 추가 시 단축어 사용
  - `advice.statusHints`, `include.path`, `remote "origin".fetch`, `interactive.singleKey` 등의 다양한 설정 언급
- 개인 `.gitconfig` 설정 예시
  - 다양한 `alias`, `tag`, `tar`, `log`, `pull`, `diff`, `difftool`, `pager`, `safe`, `advice`, `init` 설정 포함
- `delta`를 페이지로 사용하는 설정
  - 더 읽기 쉽고 구문 강조된 차이점 표시
  - 기본 브랜치로 체크아웃하는 별칭 추가
- 다양한 이메일 사용을 위한 `user.useConfigOnly` 설정
  - `user.email` 주석 처리 후, 새 리포지토리에서 커밋 시 이메일 설정
- `merge.conflictstyle` 기본값 변경 필요성
  - `diff3` 스타일이 충돌 해결에 더 많은 정보 제공
- 추가 설정들
  - `core.commentChar`, `alias.newtask`, `alias.zip`, `git checkout -`, `format.pretty`, `delta` 설정
- `branch.sort` 설정의 오해
  - 실제로는 가장 최근에 사용된 브랜치가 아닌 커밋 날짜로 정렬
- 또 다른 개인 `.gitconfig` 설정 예시
  - `alias.lg`, `alias.hist`, `alias.quick-push`, `alias.search`, `user`, `core`, `url` 설정
  - `quick-push` 별칭을 통한 간단한 워크플로우 정의 가능

위 내용은 해커뉴스 댓글에서 사용자들이 공유한 개인적인 `.gitconfig` 설정들과 그들이 선호하는 Git 설정 팁들을 요약한 것임. 설정들은 Git 사용의 효율성을 높이고, 특정 작업을 자동화하며, 사용자 경험을 개선하는 데 초점을 맞추고 있음.
