문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
git [2018/05/08 13:58] kwon37xi [Windows Git] |
git [2023/10/14 13:47] kwon37xi |
||
---|---|---|---|
줄 1: | 줄 1: | ||
====== git ====== | ====== git ====== | ||
* http:// | * http:// | ||
+ | * [[git: | ||
+ | * [[git: | ||
+ | * [[https:// | ||
+ | |||
+ | ===== Ubuntu 최신 버전 install ===== | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | <code sh> | ||
+ | sudo add-apt-repository ppa: | ||
+ | sudo apt update | ||
+ | sudo apt install git | ||
+ | </ | ||
===== Client 설정 ===== | ===== Client 설정 ===== | ||
줄 14: | 줄 26: | ||
git config --global core.filemode false | git config --global core.filemode false | ||
- | # Mac OS X 유니코드 문제 | + | # Mac OS X 유니코드 문제? 아직도 발생하나? |
- | git config --global core.precomposeunicode true | + | # git config --global core.precomposeunicode true |
</ | </ | ||
줄 24: | 줄 36: | ||
* SourceTree 사용자는 Preferences에서 **" | * SourceTree 사용자는 Preferences에서 **" | ||
+ | ===== Directory별 Include 설정 ===== | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * '' | ||
+ | [includeIf " | ||
+ | path = .git_personal_projects | ||
+ | </ | ||
+ | * '' | ||
+ | [user] | ||
+ | email = kwon37xi@gmail.com | ||
+ | name = KwonNamSon | ||
+ | </ | ||
+ | * **includeIf 는 맨 마지막에 두는 것이 좋다.** 이 이후에 나오는 설정은 '' | ||
===== Ubuntu Git 최신 버전 ===== | ===== Ubuntu Git 최신 버전 ===== | ||
* https:// | * https:// | ||
줄 31: | 줄 56: | ||
</ | </ | ||
- | ===== Windows Git ===== | + | ===== diff & difftool |
- | * https://git-scm.com/ | + | * '' |
- | * [[https:// | + | * '' |
- | * Msys 환경에서 한글이 깨질 때<code sh> | + | * '' |
- | # mintty 콘솔이 CP949일 때는 다음 처리를 하고, UTF-8일 때는 --unset 해버린다. | + | |
- | git config --global core.quotepath false # 파일명이 숫자로 보이는 문제 | + | |
- | git config --global i18n.logoutputencoding cp949 | + | |
- | git config | + | |
- | </code> | + | |
- | * [[http:// | + | |
- | * [[https:// | + | |
- | * | + | |
- | * [[http:// | + | |
- | git config --global merge.tool meld | + | |
- | git config --global mergetool.meld.cmd ' | + | |
- | git config | + | <code sh> |
- | git config | + | git difftool |
+ | git mergetool | ||
</ | </ | ||
- | | + | ===== Git Diff/Merge -> kdiff3 ===== |
- | * meld 경로는 '' | + | |
- | | + | * 파일 |
- | * '' | + | * https://github.com/KDE/kdiff3/ |
- | GIT_SSH=c:\Program Files\Putty\plink.exe | + | <code> |
+ | [diff] | ||
+ | tool = kdiff3 | ||
+ | [difftool | ||
+ | | ||
+ | [difftool] | ||
+ | prompt = false | ||
+ | keepBackup = false | ||
+ | trustExitCode = false | ||
+ | [merge] | ||
+ | tool = kdiff3 | ||
+ | [mergetool] | ||
+ | | ||
+ | | ||
+ | keepTemporaries = false | ||
+ | [mergetool " | ||
+ | path = / | ||
</ | </ | ||
- | * '' | ||
- | * '' | ||
- | * 새로운 호스트에서 clone을 하려면 먼저 '' | ||
- | plink.exe git@github.com | ||
- | </ | ||
- | ===== Password Cache ===== | ||
- | * HTTP(S) 프로토콜의 경우 명령행에서는 비밀번호 저장해두기가 곤란하다. 그래서 캐시를 사용한다. | ||
- | * [[http:// | ||
- | * Linux에서는 다음 처리로 간편하게 캐시가 끝난다.< | ||
- | # 기본 캐시 시간 15분 | ||
- | git config --global credential.helper cache | ||
- | # 캐시 시간 지정 | + | ===== Git Difftool/ |
- | git config | + | * http:// |
- | </code> | + | * [[https:// |
+ | * [[http:// | ||
- | ===== Password with Gnome-Keyring | + | < |
- | * [[http:// | + | # ------------------ M E R G E ------------------------- |
- | # on Ubuntu | + | [merge] |
- | sudo apt-get install libgnome-keyring-dev | + | tool = meld |
- | sudo make --directory=/ | + | |
- | git config | + | |
- | </ | + | |
- | ===== Password in Windows ===== | + | [mergetool " |
+ | cmd = meld --auto-merge \" | ||
+ | trustExitCode | ||
- | * [[https:// | + | [mergetool] |
+ | # don't ask if we want to skip merge | ||
+ | prompt = false | ||
- | ===== Git Diff -> meld ===== | + | # don't create backup *.orig files |
- | * http:// | + | keepBackup |
- | * '' | + | |
- | #!/bin/sh | + | # ------------------ D I F F ------------------------- |
- | meld " | + | [diff] |
- | </ | + | guitool = meld |
- | * add to '' | + | |
- | git config | + | |
- | </ | + | |
- | ===== Git Mergetool -> meld ===== | + | [difftool " |
- | * 전역 설정 <code sh> | + | cmd = meld \" |
- | git config | + | |
</ | </ | ||
===== Git Diff -> vimdiff ===== | ===== Git Diff -> vimdiff ===== | ||
+ | * [[vim: | ||
* [[http:// | * [[http:// | ||
* '' | * '' | ||
줄 113: | 줄 132: | ||
* 설정의 external 무시하고 vim을 pager로< | * 설정의 external 무시하고 vim을 pager로< | ||
git diff --no-ext-diff -w | vim -R - | git diff --no-ext-diff -w | vim -R - | ||
+ | </ | ||
+ | * 그냥 명령을 직접 주기< | ||
+ | git diff -y -t vimdiff | ||
+ | # -y 는 no prompt | ||
</ | </ | ||
===== .gitignore ===== | ===== .gitignore ===== | ||
줄 138: | 줄 161: | ||
</ | </ | ||
- | ===== Git hook ===== | ||
- | * 기본적으로는 '' | ||
- | * 전역 Hook 파일 설정 (git 2.9+)< | ||
- | git config --global core.hooksPath / | ||
- | </ | ||
===== Commit Template ===== | ===== Commit Template ===== | ||
줄 183: | 줄 201: | ||
* [[linux: | * [[linux: | ||
* [[http:// | * [[http:// | ||
+ | mkdir -p ~/ | ||
curl https:// | curl https:// | ||
줄 194: | 줄 213: | ||
export PS1=" | export PS1=" | ||
+ | </ | ||
+ | |||
+ | ===== bash auto completion ===== | ||
+ | * 대부분의 리눅스는 git 을 설치하면 이미 bash-completion 설정 파일을 함께 설치한다.< | ||
+ | source / | ||
+ | # or | ||
+ | source / | ||
+ | </ | ||
+ | * [[https:// | ||
+ | * Arch/ | ||
+ | sudo pacman -S git bash-completion | ||
+ | # shell 재실행 | ||
</ | </ | ||
줄 222: | 줄 253: | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
- | * [[http:// | + | * [[git:tig|tig]] 콘솔 기반 리포지토리 브라우저 |
* [[https:// | * [[https:// | ||
* [[http:// | * [[http:// | ||
줄 229: | 줄 260: | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
+ | * [[https:// | ||
===== 빈 디렉토리 (empty directory) 유지 ===== | ===== 빈 디렉토리 (empty directory) 유지 ===== | ||
줄 235: | 줄 267: | ||
<code sh> | <code sh> | ||
find . -type d -empty -exec touch {}/.gitkeep \; | find . -type d -empty -exec touch {}/.gitkeep \; | ||
+ | </ | ||
+ | |||
+ | ===== Windows 등에서 파일 chmod 변경 - 특히 실행(x) 권한 ===== | ||
+ | * [[https:// | ||
+ | * 아래는 Linux/*nix 계열에서는 불필요하고 작동하지도 않았다. 그냥 '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * commit 한다. | ||
+ | |||
+ | ===== shallow update not allowed ===== | ||
+ | * '' | ||
+ | * [[https:// | ||
+ | |||
+ | <code sh> | ||
+ | git fetch --unshallow origin | ||
+ | |||
+ | # 이후에 | ||
+ | git push | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== git blame ignore ===== | ||
+ | * [[https:// | ||
+ | * bulk 갱신, 포맷팅 변경 같은 경우 blame 에 자꾸 나오면 오히려 불편함. 특정 commit 을 blame에서 제외하기 | ||
+ | * [[https:// | ||
+ | |||
+ | ===== submodules ===== | ||
+ | * git 에서 다른 리포지토리를 디렉토리로 링크할 수 있음. | ||
+ | * https:// | ||
+ | * submodule 이 있는 리포지토리를 올바로 clone 하려면 '' | ||
+ | |||
+ | <code sh> | ||
+ | git clone --recursive < | ||
</ | </ | ||
줄 261: | 줄 327: | ||
* [[https:// | * [[https:// | ||
* [[http:// | * [[http:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// |