사용자 도구

사이트 도구


git

문서의 이전 판입니다!


git

Client 설정

  • https 관련 오류 발생시 env GIT_SSL_NO_VERIFY=true 붙여서 실행
  • 기본 git 사용자 정보 설정 git config --global이면 전체 시스템 공통 설정 --global 빼면 해당 리포지토리 지역 설정
    git config --global user.email "your@email.com"
    git config --global user.name "사용자명"
     
    # push/pull 기본설정 - 현재 브랜치에 대해서만 작동
    git config --global push.default simple
     
    # Windows에서 파일 모드 변경으로 인한 Update 방지
    git config --global core.filemode false
     
    # Mac OS X 유니코드 문제
    git config --global core.precomposeunicode true
    • git 1.7.12 이상 버전 사용
    • git config --global core.precomposeunicode true
      • 이걸 해도 자소 분리 현상이 발생하면 user.name을 다시 설정할 것.
    • SourceTree 사용자는 Preferences에서 “Allow SourceTree to modify your global Mercurial and Git configuration files” 체크 해제

Ubuntu Git 최신 버전

Password Cache

  • HTTP(S) 프로토콜의 경우 명령행에서는 비밀번호 저장해두기가 곤란하다. 그래서 캐시를 사용한다.
  • Linux에서는 다음 처리로 간편하게 캐시가 끝난다.
    # 기본 캐시 시간 15분
    git config --global credential.helper cache
     
    # 캐시 시간 지정
    git config --global credential.helper 'cache --timeout=7200'

Password with Gnome-Keyring

Password in Windows

Git Diff -> meld

Git Mergetool -> meld

  • 전역 설정
    git config --global merge.tool meld

Git Diff -> vimdiff

  • ~/.gitconfig
    [diff]
      external = git_diff_wrapper
    [pager]
      diff =
  • ~/bin/git_diff_wrapper
    #!/bin/sh
    vimdiff "$2" "$5"
  • 설정의 external 무시하고 vim을 pager로
    git diff --no-ext-diff -w | vim -R -

.gitignore

*.exe  # 모든 .exe 파일을 ignore 하되
!node.exe  # node.exe 는 ignore 하지 않는다. 상위 설정을 아래에서 덮어씀.

Global .gitignore

# Create a ~/.gitignore in your user directory
cd ~/
touch .gitignore
 
# Exclude bin and .metadata directories
echo "bin" >> .gitignore
echo ".metadata" >> .gitignore
echo "*~" >> .gitignore
echo "target/" >> .gitignore
 
# Configure Git to use this file
# as global .gitignore
 
git config --global core.excludesfile ~/.gitignore 

Git hook

  • 기본적으로는 projectdir/.git/hooks에 후킹 파일을 둔다.
  • 전역 Hook 파일 설정 (git 2.9+)
    git config --global core.hooksPath /path/to/my/centralized/hooks

Commit Template

$HOME/.gitmessage.txt 파일에 기본 커밋 메시지를 작성해 두고서,

git config --global commit.template $HOME/.gitmessage.txt

https certificat problem

  • 특히 윈도우 Cygwin에서 아르와 같은 오류가 발생한다. https로 clone할 때.
    Cloning into 'projectName'...
    error: error setting certificate verify locations:
      CAfile: /usr/ssl/certs/ca-bundle.crt
      CApath: none while accessing https://code.google.com/p/projectName/info/refs
    fatal: HTTP request failed
  • 해결책 1 - SSL 인증 무시
    # 환경변수로 무시
    export GIT_SSL_NO_VERIFY=true
     
    # 아니면 GIT 설정으로 무시
    git config --global http.sslVerify false
  • 인증서 깔아주기
    mkdir ~/certs
    curl http://curl.haxx.se/ca/cacert.pem -o ~/certs/cacert.pem
     
    # ~/.gitconfig 편집
    [http]
    sslCAinfo = /home/radium/certs/cacert.pem

독립 리포지토리 여러개를 하나로 묶기

Bash Prompt

  • Powerline 사용시 bash 테마를 default_leftonly로 지정하면 아래 과정이 불필요하다.
  • Bash 프롬프트에 Git Branch 이름 보여주기
    curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -o ~/.local/bin/git-prompt.sh
     
    # edit .bashrc
    source ~/.local/bin/git-prompt.sh
    export PS1='이런저런 내용 \$(__git_ps1) 나머지 '
    # 실예 녹색 프롬프트
    export PS1='\[\e[1;32m\][\u@\h \W$(__git_ps1)]\$\[\e[0m\] '
     
    # 실예 컬러 프롬프트
    export PS1="\[\033[01;32m\][\[\033[01;33m\]\u\[\033[01;36m\]@\[\033[01;31m\]\h\[\033[01;37m\]:\[\033[01;34m\]\w\[\033[01;32m\]\$(__git_ps1)]\[\033[01;35m\]\\$\[\033[00m\] "

환경변수

  • GIT_CURL_VERBOSE=1 : HTTP(S)에서 cURL 요청 주고 받는 것을 콘솔에 출력한다.

문제 해결

HTTP(S) 에서 비밀번호를 물어보지 않음

Git Hosting

Git 관련 애플리케이션

빈 디렉토리 (empty directory) 유지

find . -type d -empty -exec touch {}/.gitkeep \;

문제 해결

참조

git.1526350406.txt.gz · 마지막으로 수정됨: 2018/05/15 11:13 저자 kwon37xi