Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Git Tips

git tips의 한국어 버전 문서입니다.

English | 中文 | Русский | Tiếng Việt

팁 툴

목차

참고로 모든 명령어는 다음 버전에서 테스트 되었습니다: git version 2.7.4 (Apple Git-66).

20개 내외의 명령어로 Git 사용하기

git help everyday

Git과 함께 제공되는 유용한 가이드라인 보기

git help -g

내용으로 변경사항 검색

git log -S'<a term in the source>'

원격지 동기화 및 로컬 변경사항 덮어쓰기

git fetch origin && git reset --hard origin/master && git clean -f -d

특정 커밋까지의 모든 파일 나열하기

git ls-tree --name-only -r <commit-ish>

첫 번째 커밋 초기화

git update-ref -d HEAD

충돌된 모든 파일 나열하기

git diff --name-only --diff-filter=U

특정 커밋에서 변경된 모든 파일 나열하기

git diff-tree --no-commit-id --name-only -r <commit-ish>

마지막 커밋 이후로 스테이징되지 않은 변경사항 보기

git diff

커밋을 하기 위해 스테이징된 변경사항 보기

git diff --cached

다른 방법:

git diff --staged

스테이징된 변경사항과 스테이징되지 않은 변경사항 모두 보기

git diff HEAD

이미 마스터 브랜치에 머지된 모든 브랜치 나열하기

git branch --merged master

이전 브랜치로 전환하기

git checkout -

다른 방법:

git checkout @{-1}

이미 마스터 브랜치에 머지된 모든 브랜치들 삭제하기

git branch --merged master | grep -v '^\*'| xargs -n 1 git branch -d

다른 방법:

git branch --merged master | grep -v '^\*\| master'| xargs -n 1 git branch -d # will not delete master if master is not checked out

모든 브랜치들 및 그 브랜치들의 업스트림과 마지막 커밋 나열하기

git branch -vv

업스트림 브랜치 설정 (트래킹)

git branch -u origin/mybranch

로컬 브랜치 삭제

git branch -d <local_branchname>

원격 브랜치 삭제

git push origin --delete <remote_branchname>

다른 방법:

git push origin :<remote_branchname>

로컬 태그 삭제

git tag -d <tag-name>

원격 태그 삭제

git push origin :refs/tags/<tag-name>

로컬 변경사항을 헤드의 마지막 내용으로 되돌리기

git checkout -- <file_name>

Revert: 새로운 커밋을 생성하면서 커밋 되돌리기

git revert <commit-ish>

Reset: 커밋 제거 (프라이빗 브랜치에서만 사용하길 권고)

git reset <commit-ish>

이전 커밋 메시지 변경

git commit -v --amend

브랜치의 커밋중 업스트림에 머지되지 않은 커밋 히스토리 보기

git cherry -v master

Author 수정하기

git commit --amend --author='Author Name <email@address.com>'

글로벌 설정에서 변경된 author로 author 재설정하기

git commit --amend --reset-author --no-edit

원격지 URL 변경하기

git remote set-url origin <URL>

모든 원격지 레퍼런스 리스트 나열하기

git remote

다른 방법:

git remote show

모든 로컬 및 원격지 브랜치 나열하기

git branch -a

원격지 브랜치만 나열하기

git branch -r

파일 변경사항의 전체가 아닌 일부만 스테이징하기

git add -p

Git 배시 자동완성 사용하기

curl http://git.io/vfhol >~/.git-completion.bash &&echo'[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash'>>~/.bashrc

2주 전부터 현재까지의 변경사항 보기

git log --no-merges --raw --since='2 weeks ago'

다른 방법:

git whatchanged --since='2 weeks ago'

마스터로부터 포크한 이후에 생성된 모든 커밋 보기

git log --no-merges --stat --reverse master..

cherry-pick을 사용해 브랜치간 커밋 가져오기

git checkout <branch-name>&& git cherry-pick <commit-ish>

해당 커밋 해시를 가지고 있는 브랜치들 검색하기

git branch -a --contains <commit-ish>

다른 방법:

git branch --contains <commit-ish>

Git 명령어 별칭 지정

git config --global alias.<handle><command> git config --global alias.st status

커밋하지 않은 트래킹된 파일들의 상태 저장하기

git stash

다른 방법:

git stash save

스테이징되지 않은 변경사항들의 현재 상태를 트래킹된 파일로 저장하기

git stash -k

다른 방법:

git stash --keep-index
git stash save --keep-index

트래킹되지 않은 파일들까지 모두 포함해 현재 상태 저장하기

git stash -u

다른 방법:

git stash save -u
git stash save --include-untracked

현재 상태를 메시지와 함께 저장하기

git stash save <message>

모든 무시된 파일, 트래킹되지 않은 파일, 트래킹된 파일들의 현재 상태 저장하기

git stash -a

다른 방법:

git stash --all
git stash save --all

저장된 모든 스태시 리스트 나열하기

git stash list

스태시 리스트에서 삭제하지 않고 스태시 적용하기

git stash apply <stash@{n}>

마지막으로 저장된 스태시 상태를 적용하고 스태시 리스트에서 삭제하기

git stash pop

다른 방법:

git stash apply stash@{0} && git stash drop stash@{0}

저장된 모든 스태시 삭제하기

git stash clear

다른 방법:

git stash drop <stash@{n}>

스태시로부터 단일 파일 가져오기

git checkout <stash@{n}> -- <file_path>

다른 방법:

git checkout stash@{0} -- <file_path>

트래킹된 파일들 모두 보기

git ls-files -t

트래킹되지 않은 파일들 모두 보기

git ls-files --others

무시된 파일들 모두 보기

git ls-files --others -i --exclude-standard

저장소에 새로운 워킹 트리 생성하기 (git 2.5)

git worktree add -b <branch-name><path><start-point>

HEAD로부터 새로운 워킹 트리 생성하기

git worktree add --detach <path> HEAD

파일을 삭제하지 않고 언트래킹하기

git rm --cached <file_path>

다른 방법:

git rm --cached -r <directory_path>

트래킹되지 않은 파일/디렉토리를 실제로 삭제하기 전에 어떤 파일/디렉토리가 삭제되는지 테스트 해보기

git clean -n

트래킹되지 않은 파일들 강제로 삭제하기

git clean -f

트래킹되지 않은 디렉토리 강제로 삭제하기

git clean -f -d

다른 방법:

git clean -df

모든 서브 모듈 업데이트하기

git submodule foreach git pull

다른 방법:

git submodule update --init --recursive
git submodule update --remote

현재 브랜치에서 아직 마스터에 머지되지 않은 모든 커밋들 보기

git cherry -v master

다른 방법:

git cherry -v master <branch-to-be-merged>

브랜치명 수정하기

git branch -m <new-branch-name>

다른 방법:

git branch -m [<old-branch-name>] <new-branch-name>

'feature' 브랜치를 마스터에 리베이스한 후 마스터에 머지하기

git rebase master feature && git checkout master && git merge -

마스터 브랜치 아카이브

git archive master --format=zip --output=master.zip

커밋 메시지는 변경하지 않고 이전 커밋 변경하기

git add --all && git commit --amend --no-edit

원격지에서 삭제된 원격 브랜치 레퍼런스 제거하기

git fetch -p

다른 방법:

git remote prune origin

첫 리비전의 커밋 해시값 가져오기

 git rev-list --reverse HEAD | head -1

다른 방법:

git rev-list --max-parents=0 HEAD
git log --pretty=oneline | tail -1 | cut -c 1-40
git log --pretty=oneline --reverse | head -1 | cut -c 1-40

버전 트리 시각화

git log --pretty=oneline --graph --decorate --all

다른 방법:

gitk --all

트래킹된 하위폴더를 gh-pages 브랜치로 배포하기

git subtree push --prefix subfolder_name origin gh-pages

subtree를 사용해 저장소에 프로젝트 추가하기

git subtree add --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master

subtree를 사용해 관련된 프로젝트의 최신 변경사항을 저장소로 가져오기

git subtree pull --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master

브랜치를 히스토리와 함께 파일로 추출하기

git bundle create <file><branch-name>

번들 가져오기

git clone repo.bundle <repo-dir> -b <branch-name>

현재 브랜치명 가져오기

git rev-parse --abbrev-ref HEAD

커밋시 파일 무시하기 (예를 들어, Changelog 파일)

git update-index --assume-unchanged Changelog; git commit -a; git update-index --no-assume-unchanged Changelog

리베이스 전에 변경사항 스태시하기

git rebase --autostash

ID로 풀 리퀘스트를 로컬 저장소로 가져오기

git fetch origin pull/<id>/head:<branch-name>

다른 방법:

git pull origin pull/<id>/head:<branch-name>

현재 브랜치의 가장 최근 태그 보기

git describe --tags --abbrev=0

diff 워드 단위로 보기

git diff --word-diff

diff 도구를 사용해 변경사항 보기

git difftool -t <commit1><commit2><path>

트래킹된 파일의 변경사항 무시하기

git update-index --assume-unchanged <file_name>

assume-unchanged 되돌리기

git update-index --no-assume-unchanged <file_name>

.gitignore에 명시된 파일들 삭제하기

git clean -X -f

삭제된 파일 복구하기

git checkout <deleting_commit>^ -- <file_path>

특정 커밋으로의 파일로 복구하기

git checkout <commit-ish> -- <file_path>

pull시 머지하는 대신 항상 리베이스 하기

git config --global pull.rebase true

다른 방법:

#git < 1.7.9
git config --global branch.autosetuprebase always

모든 별칭과 설정값들 나열하기

git config --list

대소문자 구별 활성화

git config --global core.ignorecase false

커스텀 에디터 추가하기

git config --global core.editor '$EDITOR'

오타 자동 수정 활성화

git config --global help.autocorrect 1

변경사항이 어떤 릴리즈에 속하는지 확인하기

git name-rev --name-only <SHA-1>

명령어 테스트 해보기 (dry-run 플래그를 지원하는 모든 명령어에서 가능)

git clean -fd --dry-run

커밋이 이전 커밋의 수정 버전임을 표시하기

git commit --fixup <SHA-1>

fixup 커밋을 일반 커밋으로 스쿼시하기

git rebase -i --autosquash

커밋시 스테이징된 파일들 스킵하기

git commit --only <file_path>

대화형으로 스테이징하기

git add -i

무시된 파일들 나열하기

git check-ignore *

무시된 파일들 상태 출력

git status --ignored

Branch2에는 없고 Branch1에만 있는 커밋들 나열하기

git log Branch1 ^Branch2

마지막 n개의 커밋 나열하기

git log -<n>

다른 방법:

git log -n <n>

이전에 충돌을 해결했던 방법을 기록하고 재사용하기

git config --global rerere.enabled 1

모든 충돌된 파일들 에디터로 열기

git diff --name-only | uniq | xargs $EDITOR

unpacked 오브젝트의 갯수와 디스크 사용량 보기

git count-objects --human-readable

오브젝트 데이터베이스에서 도달할 수 없는 오브젝트들 제거하기

git gc --prune=now --aggressive

gitweb으로 워킹 디렉토리 탐색하기

git instaweb [--local] [--httpd=<httpd>] [--port=<port>] [--browser=<browser>]

커밋 로그에서 GPG 시그니쳐 보기

git log --show-signature

글로벌 설정에서 엔트리 제거하기

git config --global --unset <entry-name>

히스토리가 없는 새로운 브랜치로 체크아웃하기

git checkout --orphan <branch_name>

다른 브랜치에서 파일내용 가져오기

git show <branch_name>:<file_name>

루트 커밋과 머지 커밋만 나열하기

git log --first-parent

대화형 리베이스로 이전 두 커밋 수정하기

git rebase --interactive HEAD~2

작업중인 브랜치들 모두 나열하기

git checkout master && git branch --no-merged

이진 탐색으로 좋은/안좋은 커밋 검색하기

git bisect start # Search start 
git bisect bad # Set point to bad commit 
git bisect good v2.6.13-rc2 # Set point to good commit|tag 
git bisect bad # Say current state is bad 
git bisect good # Say current state is good 
git bisect reset # Finish search 

pre-commit과 commit-msg 깃 후킹 우회하기

git commit --no-verify

특정 파일에 대한 커밋과 변경사항 나열하기 (이름이 바뀐 파일도 추적)

git log --follow -p -- <file_path>

단일 브랜치 클론

git clone -b <branch-name> --single-branch https://github.com/user/repo.git

새로운 브랜치 생성과 동시에 스위칭

git checkout -b <branch-name>

다른 방법:

git branch <branch-name>&& git checkout <branch-name>

커밋시 파일 모드 변경 무시

git config core.fileMode false

Git 터미널 색상 출력 비활성화

git config --global color.ui false

특정 명령어에 대한 색상 설정 지정하기

git config --global <specific command e.g branch, diff><true, false or always>

모든 로컬 브랜치를 최근 커밋 날짜를 기준으로 정렬해 나열하기

git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/

트래킹된 파일에서 패턴(정규식이나 문자열)에 매칭되는 라인 검색

git grep --heading --line-number 'foo bar'

저장소의 얕은 카피 버전 클론하기

git clone https://github.com/user/repo.git --depth 1

모든 브랜치에서 주어진 텍스트로 커밋 로그 검색하기

git log --all --grep='<given-text>'

브랜치의 첫 커밋 가져오기 (마스터 브랜치로부터 시작된)

git log master..<branch-name> --oneline | tail -1

스테이징된 파일들 언스테이징하기

git reset HEAD <file-name>

원격 저장소에 강제 푸시하기

git push -f <remote-name><branch-name>

저장소명 추가하기

git remote add <remote-nickname><remote-url>

주어진 파일의 각 라인별 author, 시간 그리고 최종 리비전명 보기

git blame <file-name>

Author와 제목으로 커밋 그룹핑하기

git shortlog

다른 사람이 작업한 내용을 덮어쓰지 않고 강제 푸시하기

git push --force-with-lease <remote-name><branch-name>

특정 author가 기여한 라인수 보기

git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | gawk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s removed lines: %s total lines: %s", add, subs, loc }' -

다른 방법:

git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | awk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s, removed lines: %s, total lines: %s", add, subs, loc }' - # on Mac OSX

Revert: 머지 복구하기

git revert -m 1 <commit-ish>

특정 브랜치의 커밋 수 출력하기

git rev-list --count <branch-name>

별칭: git undo

git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'

오브젝트에 노트(메모) 추가하기

git notes add -m 'Note on the previous commit....'

모든 깃 노트 보기

git log --show-notes='*'

다른 저장소에 있는 커밋 적용하기

git --git-dir=<source-dir>/.git format-patch -k -1 --stdout <SHA1>| git am -3 -k

페치 레퍼런스 지정하기

git fetch origin master:refs/remotes/origin/mymaster

두 브랜치의 공통 조상 커밋 찾기

diff -u <(git rev-list --first-parent BranchA)<(git rev-list --first-parent BranchB)| sed -ne 's/^ //p'| head -1

푸시되지 않은 커밋들 나열하기

git log --branches --not --remotes

다른 방법:

git log @{u}..
git cherry -v

공백 변경사항을 제외한 모든 변경사항 추가하기

git diff --ignore-all-space | git apply --cached

깃 설정 [로컬/글로벌] 수정하기

git config [--global] --edit

특정 구간에서 blame 정보 보기

git blame -L <start>,<end>

Git의 논리적 변수 보기

git var -l |<variable>

패치 파일 미리 포맷팅하기

git format-patch -M upstream..topic

저장소명 가져오기

git rev-parse --show-toplevel

특정 날짜 구간 사이의 커밋 로그 출력하기

git log --since='FEB 1 2017' --until='FEB 14 2017'

로그에서 author 제외하기

git log --perl-regexp --author='^((?!excluded-author-regex).*)

브랜치의 수정사항 요약하기

git request-pull v1.0 https://git.ko.xz/project master:for-linus

원격 저장소의 모든 레퍼런스 나열하기

git ls-remote git://git.kernel.org/pub/scm/git/git.git

트래킹되지 않은 파일들 백업하기

git ls-files --others -i --exclude-standard | xargs zip untracked.zip

모든 git 명령어 별칭 나열하기

git config -l | grep alias| sed 's/^alias\.//g'

다른 방법:

git config -l | grep alias| cut -d '.' -f 2

git 상태 간략하게 보기

git status --short --branch

하루 전의 커밋으로 체크아웃하기

git checkout master@{yesterday}

About

📚 Git 팁 모음집 (https://github.com/git-tips/tips 한국어 버전)

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Git Tips

git tips의 한국어 버전 문서입니다.

English | 中文 | Русский | Tiếng Việt

팁 툴

목차

참고로 모든 명령어는 다음 버전에서 테스트 되었습니다: git version 2.7.4 (Apple Git-66).

20개 내외의 명령어로 Git 사용하기

git help everyday

Git과 함께 제공되는 유용한 가이드라인 보기

git help -g

내용으로 변경사항 검색

git log -S'<a term in the source>'

원격지 동기화 및 로컬 변경사항 덮어쓰기

git fetch origin && git reset --hard origin/master && git clean -f -d

특정 커밋까지의 모든 파일 나열하기

git ls-tree --name-only -r <commit-ish>

첫 번째 커밋 초기화

git update-ref -d HEAD

충돌된 모든 파일 나열하기

git diff --name-only --diff-filter=U

특정 커밋에서 변경된 모든 파일 나열하기

git diff-tree --no-commit-id --name-only -r <commit-ish>

마지막 커밋 이후로 스테이징되지 않은 변경사항 보기

git diff

커밋을 하기 위해 스테이징된 변경사항 보기

git diff --cached

다른 방법:

git diff --staged

스테이징된 변경사항과 스테이징되지 않은 변경사항 모두 보기

git diff HEAD

이미 마스터 브랜치에 머지된 모든 브랜치 나열하기

git branch --merged master

이전 브랜치로 전환하기

git checkout -

다른 방법:

git checkout @{-1}

이미 마스터 브랜치에 머지된 모든 브랜치들 삭제하기

git branch --merged master | grep -v '^\*'| xargs -n 1 git branch -d

다른 방법:

git branch --merged master | grep -v '^\*\| master'| xargs -n 1 git branch -d # will not delete master if master is not checked out

모든 브랜치들 및 그 브랜치들의 업스트림과 마지막 커밋 나열하기

git branch -vv

업스트림 브랜치 설정 (트래킹)

git branch -u origin/mybranch

로컬 브랜치 삭제

git branch -d <local_branchname>

원격 브랜치 삭제

git push origin --delete <remote_branchname>

다른 방법:

git push origin :<remote_branchname>

로컬 태그 삭제

git tag -d <tag-name>

원격 태그 삭제

git push origin :refs/tags/<tag-name>

로컬 변경사항을 헤드의 마지막 내용으로 되돌리기

git checkout -- <file_name>

Revert: 새로운 커밋을 생성하면서 커밋 되돌리기

git revert <commit-ish>

Reset: 커밋 제거 (프라이빗 브랜치에서만 사용하길 권고)

git reset <commit-ish>

이전 커밋 메시지 변경

git commit -v --amend

브랜치의 커밋중 업스트림에 머지되지 않은 커밋 히스토리 보기

git cherry -v master

Author 수정하기

git commit --amend --author='Author Name <email@address.com>'

글로벌 설정에서 변경된 author로 author 재설정하기

git commit --amend --reset-author --no-edit

원격지 URL 변경하기

git remote set-url origin <URL>

모든 원격지 레퍼런스 리스트 나열하기

git remote

다른 방법:

git remote show

모든 로컬 및 원격지 브랜치 나열하기

git branch -a

원격지 브랜치만 나열하기

git branch -r

파일 변경사항의 전체가 아닌 일부만 스테이징하기

git add -p

Git 배시 자동완성 사용하기

curl http://git.io/vfhol >~/.git-completion.bash &&echo'[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash'>>~/.bashrc

2주 전부터 현재까지의 변경사항 보기

git log --no-merges --raw --since='2 weeks ago'

다른 방법:

git whatchanged --since='2 weeks ago'

마스터로부터 포크한 이후에 생성된 모든 커밋 보기

git log --no-merges --stat --reverse master..

cherry-pick을 사용해 브랜치간 커밋 가져오기

git checkout <branch-name>&& git cherry-pick <commit-ish>

해당 커밋 해시를 가지고 있는 브랜치들 검색하기

git branch -a --contains <commit-ish>

다른 방법:

git branch --contains <commit-ish>

Git 명령어 별칭 지정

git config --global alias.<handle><command> git config --global alias.st status

커밋하지 않은 트래킹된 파일들의 상태 저장하기

git stash

다른 방법:

git stash save

스테이징되지 않은 변경사항들의 현재 상태를 트래킹된 파일로 저장하기

git stash -k

다른 방법:

git stash --keep-index
git stash save --keep-index

트래킹되지 않은 파일들까지 모두 포함해 현재 상태 저장하기

git stash -u

다른 방법:

git stash save -u
git stash save --include-untracked

현재 상태를 메시지와 함께 저장하기

git stash save <message>

모든 무시된 파일, 트래킹되지 않은 파일, 트래킹된 파일들의 현재 상태 저장하기

git stash -a

다른 방법:

git stash --all
git stash save --all

저장된 모든 스태시 리스트 나열하기

git stash list

스태시 리스트에서 삭제하지 않고 스태시 적용하기

git stash apply <stash@{n}>

마지막으로 저장된 스태시 상태를 적용하고 스태시 리스트에서 삭제하기

git stash pop

다른 방법:

git stash apply stash@{0} && git stash drop stash@{0}

저장된 모든 스태시 삭제하기

git stash clear

다른 방법:

git stash drop <stash@{n}>

스태시로부터 단일 파일 가져오기

git checkout <stash@{n}> -- <file_path>

다른 방법:

git checkout stash@{0} -- <file_path>

트래킹된 파일들 모두 보기

git ls-files -t

트래킹되지 않은 파일들 모두 보기

git ls-files --others

무시된 파일들 모두 보기

git ls-files --others -i --exclude-standard

저장소에 새로운 워킹 트리 생성하기 (git 2.5)

git worktree add -b <branch-name><path><start-point>

HEAD로부터 새로운 워킹 트리 생성하기

git worktree add --detach <path> HEAD

파일을 삭제하지 않고 언트래킹하기

git rm --cached <file_path>

다른 방법:

git rm --cached -r <directory_path>

트래킹되지 않은 파일/디렉토리를 실제로 삭제하기 전에 어떤 파일/디렉토리가 삭제되는지 테스트 해보기

git clean -n

트래킹되지 않은 파일들 강제로 삭제하기

git clean -f

트래킹되지 않은 디렉토리 강제로 삭제하기

git clean -f -d

다른 방법:

git clean -df

모든 서브 모듈 업데이트하기

git submodule foreach git pull

다른 방법:

git submodule update --init --recursive
git submodule update --remote

현재 브랜치에서 아직 마스터에 머지되지 않은 모든 커밋들 보기

git cherry -v master

다른 방법:

git cherry -v master <branch-to-be-merged>

브랜치명 수정하기

git branch -m <new-branch-name>

다른 방법:

git branch -m [<old-branch-name>] <new-branch-name>

'feature' 브랜치를 마스터에 리베이스한 후 마스터에 머지하기

git rebase master feature && git checkout master && git merge -

마스터 브랜치 아카이브

git archive master --format=zip --output=master.zip

커밋 메시지는 변경하지 않고 이전 커밋 변경하기

git add --all && git commit --amend --no-edit

원격지에서 삭제된 원격 브랜치 레퍼런스 제거하기

git fetch -p

다른 방법:

git remote prune origin

첫 리비전의 커밋 해시값 가져오기

 git rev-list --reverse HEAD | head -1

다른 방법:

git rev-list --max-parents=0 HEAD
git log --pretty=oneline | tail -1 | cut -c 1-40
git log --pretty=oneline --reverse | head -1 | cut -c 1-40

버전 트리 시각화

git log --pretty=oneline --graph --decorate --all

다른 방법:

gitk --all

트래킹된 하위폴더를 gh-pages 브랜치로 배포하기

git subtree push --prefix subfolder_name origin gh-pages

subtree를 사용해 저장소에 프로젝트 추가하기

git subtree add --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master

subtree를 사용해 관련된 프로젝트의 최신 변경사항을 저장소로 가져오기

git subtree pull --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master

브랜치를 히스토리와 함께 파일로 추출하기

git bundle create <file><branch-name>

번들 가져오기

git clone repo.bundle <repo-dir> -b <branch-name>

현재 브랜치명 가져오기

git rev-parse --abbrev-ref HEAD

커밋시 파일 무시하기 (예를 들어, Changelog 파일)

git update-index --assume-unchanged Changelog; git commit -a; git update-index --no-assume-unchanged Changelog

리베이스 전에 변경사항 스태시하기

git rebase --autostash

ID로 풀 리퀘스트를 로컬 저장소로 가져오기

git fetch origin pull/<id>/head:<branch-name>

다른 방법:

git pull origin pull/<id>/head:<branch-name>

현재 브랜치의 가장 최근 태그 보기

git describe --tags --abbrev=0

diff 워드 단위로 보기

git diff --word-diff

diff 도구를 사용해 변경사항 보기

git difftool -t <commit1><commit2><path>

트래킹된 파일의 변경사항 무시하기

git update-index --assume-unchanged <file_name>

assume-unchanged 되돌리기

git update-index --no-assume-unchanged <file_name>

.gitignore에 명시된 파일들 삭제하기

git clean -X -f

삭제된 파일 복구하기

git checkout <deleting_commit>^ -- <file_path>

특정 커밋으로의 파일로 복구하기

git checkout <commit-ish> -- <file_path>

pull시 머지하는 대신 항상 리베이스 하기

git config --global pull.rebase true

다른 방법:

#git < 1.7.9
git config --global branch.autosetuprebase always

모든 별칭과 설정값들 나열하기

git config --list

대소문자 구별 활성화

git config --global core.ignorecase false

커스텀 에디터 추가하기

git config --global core.editor '$EDITOR'

오타 자동 수정 활성화

git config --global help.autocorrect 1

변경사항이 어떤 릴리즈에 속하는지 확인하기

git name-rev --name-only <SHA-1>

명령어 테스트 해보기 (dry-run 플래그를 지원하는 모든 명령어에서 가능)

git clean -fd --dry-run

커밋이 이전 커밋의 수정 버전임을 표시하기

git commit --fixup <SHA-1>

fixup 커밋을 일반 커밋으로 스쿼시하기

git rebase -i --autosquash

커밋시 스테이징된 파일들 스킵하기

git commit --only <file_path>

대화형으로 스테이징하기

git add -i

무시된 파일들 나열하기

git check-ignore *

무시된 파일들 상태 출력

git status --ignored

Branch2에는 없고 Branch1에만 있는 커밋들 나열하기

git log Branch1 ^Branch2

마지막 n개의 커밋 나열하기

git log -<n>

다른 방법:

git log -n <n>

이전에 충돌을 해결했던 방법을 기록하고 재사용하기

git config --global rerere.enabled 1

모든 충돌된 파일들 에디터로 열기

git diff --name-only | uniq | xargs $EDITOR

unpacked 오브젝트의 갯수와 디스크 사용량 보기

git count-objects --human-readable

오브젝트 데이터베이스에서 도달할 수 없는 오브젝트들 제거하기

git gc --prune=now --aggressive

gitweb으로 워킹 디렉토리 탐색하기

git instaweb [--local] [--httpd=<httpd>] [--port=<port>] [--browser=<browser>]

커밋 로그에서 GPG 시그니쳐 보기

git log --show-signature

글로벌 설정에서 엔트리 제거하기

git config --global --unset <entry-name>

히스토리가 없는 새로운 브랜치로 체크아웃하기

git checkout --orphan <branch_name>

다른 브랜치에서 파일내용 가져오기

git show <branch_name>:<file_name>

루트 커밋과 머지 커밋만 나열하기

git log --first-parent

대화형 리베이스로 이전 두 커밋 수정하기

git rebase --interactive HEAD~2

작업중인 브랜치들 모두 나열하기

git checkout master && git branch --no-merged

이진 탐색으로 좋은/안좋은 커밋 검색하기

git bisect start # Search start 
git bisect bad # Set point to bad commit 
git bisect good v2.6.13-rc2 # Set point to good commit|tag 
git bisect bad # Say current state is bad 
git bisect good # Say current state is good 
git bisect reset # Finish search 

pre-commit과 commit-msg 깃 후킹 우회하기

git commit --no-verify

특정 파일에 대한 커밋과 변경사항 나열하기 (이름이 바뀐 파일도 추적)

git log --follow -p -- <file_path>

단일 브랜치 클론

git clone -b <branch-name> --single-branch https://github.com/user/repo.git

새로운 브랜치 생성과 동시에 스위칭

git checkout -b <branch-name>

다른 방법:

git branch <branch-name>&& git checkout <branch-name>

커밋시 파일 모드 변경 무시

git config core.fileMode false

Git 터미널 색상 출력 비활성화

git config --global color.ui false

특정 명령어에 대한 색상 설정 지정하기

git config --global <specific command e.g branch, diff><true, false or always>

모든 로컬 브랜치를 최근 커밋 날짜를 기준으로 정렬해 나열하기

git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/

트래킹된 파일에서 패턴(정규식이나 문자열)에 매칭되는 라인 검색

git grep --heading --line-number 'foo bar'

저장소의 얕은 카피 버전 클론하기

git clone https://github.com/user/repo.git --depth 1

모든 브랜치에서 주어진 텍스트로 커밋 로그 검색하기

git log --all --grep='<given-text>'

브랜치의 첫 커밋 가져오기 (마스터 브랜치로부터 시작된)

git log master..<branch-name> --oneline | tail -1

스테이징된 파일들 언스테이징하기

git reset HEAD <file-name>

원격 저장소에 강제 푸시하기

git push -f <remote-name><branch-name>

저장소명 추가하기

git remote add <remote-nickname><remote-url>

주어진 파일의 각 라인별 author, 시간 그리고 최종 리비전명 보기

git blame <file-name>

Author와 제목으로 커밋 그룹핑하기

git shortlog

다른 사람이 작업한 내용을 덮어쓰지 않고 강제 푸시하기

git push --force-with-lease <remote-name><branch-name>

특정 author가 기여한 라인수 보기

git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | gawk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s removed lines: %s total lines: %s", add, subs, loc }' -

다른 방법:

git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | awk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s, removed lines: %s, total lines: %s", add, subs, loc }' - # on Mac OSX

Revert: 머지 복구하기

git revert -m 1 <commit-ish>

특정 브랜치의 커밋 수 출력하기

git rev-list --count <branch-name>

별칭: git undo

git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'

오브젝트에 노트(메모) 추가하기

git notes add -m 'Note on the previous commit....'

모든 깃 노트 보기

git log --show-notes='*'

다른 저장소에 있는 커밋 적용하기

git --git-dir=<source-dir>/.git format-patch -k -1 --stdout <SHA1>| git am -3 -k

페치 레퍼런스 지정하기

git fetch origin master:refs/remotes/origin/mymaster

두 브랜치의 공통 조상 커밋 찾기

diff -u <(git rev-list --first-parent BranchA)<(git rev-list --first-parent BranchB)| sed -ne 's/^ //p'| head -1

푸시되지 않은 커밋들 나열하기

git log --branches --not --remotes

다른 방법:

git log @{u}..
git cherry -v

공백 변경사항을 제외한 모든 변경사항 추가하기

git diff --ignore-all-space | git apply --cached

깃 설정 [로컬/글로벌] 수정하기

git config [--global] --edit

특정 구간에서 blame 정보 보기

git blame -L <start>,<end>

Git의 논리적 변수 보기

git var -l |<variable>

패치 파일 미리 포맷팅하기

git format-patch -M upstream..topic

저장소명 가져오기

git rev-parse --show-toplevel

특정 날짜 구간 사이의 커밋 로그 출력하기

git log --since='FEB 1 2017' --until='FEB 14 2017'

로그에서 author 제외하기

git log --perl-regexp --author='^((?!excluded-author-regex).*)

브랜치의 수정사항 요약하기

git request-pull v1.0 https://git.ko.xz/project master:for-linus

원격 저장소의 모든 레퍼런스 나열하기

git ls-remote git://git.kernel.org/pub/scm/git/git.git

트래킹되지 않은 파일들 백업하기

git ls-files --others -i --exclude-standard | xargs zip untracked.zip

모든 git 명령어 별칭 나열하기

git config -l | grep alias| sed 's/^alias\.//g'

다른 방법:

git config -l | grep alias| cut -d '.' -f 2

git 상태 간략하게 보기

git status --short --branch

하루 전의 커밋으로 체크아웃하기

git checkout master@{yesterday}

About

📚 Git 팁 모음집 (https://github.com/git-tips/tips 한국어 버전)

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Git Tips

git tips의 한국어 버전 문서입니다.

English | 中文 | Русский | Tiếng Việt

팁 툴

목차

참고로 모든 명령어는 다음 버전에서 테스트 되었습니다: git version 2.7.4 (Apple Git-66).

20개 내외의 명령어로 Git 사용하기

git help everyday

Git과 함께 제공되는 유용한 가이드라인 보기

git help -g

내용으로 변경사항 검색

git log -S'<a term in the source>'

원격지 동기화 및 로컬 변경사항 덮어쓰기

git fetch origin && git reset --hard origin/master && git clean -f -d

특정 커밋까지의 모든 파일 나열하기

git ls-tree --name-only -r <commit-ish>

첫 번째 커밋 초기화

git update-ref -d HEAD

충돌된 모든 파일 나열하기

git diff --name-only --diff-filter=U

특정 커밋에서 변경된 모든 파일 나열하기

git diff-tree --no-commit-id --name-only -r <commit-ish>

마지막 커밋 이후로 스테이징되지 않은 변경사항 보기

git diff

커밋을 하기 위해 스테이징된 변경사항 보기

git diff --cached

다른 방법:

git diff --staged

스테이징된 변경사항과 스테이징되지 않은 변경사항 모두 보기

git diff HEAD

이미 마스터 브랜치에 머지된 모든 브랜치 나열하기

git branch --merged master

이전 브랜치로 전환하기

git checkout -

다른 방법:

git checkout @{-1}

이미 마스터 브랜치에 머지된 모든 브랜치들 삭제하기

git branch --merged master | grep -v '^\*'| xargs -n 1 git branch -d

다른 방법:

git branch --merged master | grep -v '^\*\| master'| xargs -n 1 git branch -d # will not delete master if master is not checked out

모든 브랜치들 및 그 브랜치들의 업스트림과 마지막 커밋 나열하기

git branch -vv

업스트림 브랜치 설정 (트래킹)

git branch -u origin/mybranch

로컬 브랜치 삭제

git branch -d <local_branchname>

원격 브랜치 삭제

git push origin --delete <remote_branchname>

다른 방법:

git push origin :<remote_branchname>

로컬 태그 삭제

git tag -d <tag-name>

원격 태그 삭제

git push origin :refs/tags/<tag-name>

로컬 변경사항을 헤드의 마지막 내용으로 되돌리기

git checkout -- <file_name>

Revert: 새로운 커밋을 생성하면서 커밋 되돌리기

git revert <commit-ish>

Reset: 커밋 제거 (프라이빗 브랜치에서만 사용하길 권고)

git reset <commit-ish>

이전 커밋 메시지 변경

git commit -v --amend

브랜치의 커밋중 업스트림에 머지되지 않은 커밋 히스토리 보기

git cherry -v master

Author 수정하기

git commit --amend --author='Author Name <email@address.com>'

글로벌 설정에서 변경된 author로 author 재설정하기

git commit --amend --reset-author --no-edit

원격지 URL 변경하기

git remote set-url origin <URL>

모든 원격지 레퍼런스 리스트 나열하기

git remote

다른 방법:

git remote show

모든 로컬 및 원격지 브랜치 나열하기

git branch -a

원격지 브랜치만 나열하기

git branch -r

파일 변경사항의 전체가 아닌 일부만 스테이징하기

git add -p

Git 배시 자동완성 사용하기

curl http://git.io/vfhol >~/.git-completion.bash &&echo'[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash'>>~/.bashrc

2주 전부터 현재까지의 변경사항 보기

git log --no-merges --raw --since='2 weeks ago'

다른 방법:

git whatchanged --since='2 weeks ago'

마스터로부터 포크한 이후에 생성된 모든 커밋 보기

git log --no-merges --stat --reverse master..

cherry-pick을 사용해 브랜치간 커밋 가져오기

git checkout <branch-name>&& git cherry-pick <commit-ish>

해당 커밋 해시를 가지고 있는 브랜치들 검색하기

git branch -a --contains <commit-ish>

다른 방법:

git branch --contains <commit-ish>

Git 명령어 별칭 지정

git config --global alias.<handle><command> git config --global alias.st status

커밋하지 않은 트래킹된 파일들의 상태 저장하기

git stash

다른 방법:

git stash save

스테이징되지 않은 변경사항들의 현재 상태를 트래킹된 파일로 저장하기

git stash -k

다른 방법:

git stash --keep-index
git stash save --keep-index

트래킹되지 않은 파일들까지 모두 포함해 현재 상태 저장하기

git stash -u

다른 방법:

git stash save -u
git stash save --include-untracked

현재 상태를 메시지와 함께 저장하기

git stash save <message>

모든 무시된 파일, 트래킹되지 않은 파일, 트래킹된 파일들의 현재 상태 저장하기

git stash -a

다른 방법:

git stash --all
git stash save --all

저장된 모든 스태시 리스트 나열하기

git stash list

스태시 리스트에서 삭제하지 않고 스태시 적용하기

git stash apply <stash@{n}>

마지막으로 저장된 스태시 상태를 적용하고 스태시 리스트에서 삭제하기

git stash pop

다른 방법:

git stash apply stash@{0} && git stash drop stash@{0}

저장된 모든 스태시 삭제하기

git stash clear

다른 방법:

git stash drop <stash@{n}>

스태시로부터 단일 파일 가져오기

git checkout <stash@{n}> -- <file_path>

다른 방법:

git checkout stash@{0} -- <file_path>

트래킹된 파일들 모두 보기

git ls-files -t

트래킹되지 않은 파일들 모두 보기

git ls-files --others

무시된 파일들 모두 보기

git ls-files --others -i --exclude-standard

저장소에 새로운 워킹 트리 생성하기 (git 2.5)

git worktree add -b <branch-name><path><start-point>

HEAD로부터 새로운 워킹 트리 생성하기

git worktree add --detach <path> HEAD

파일을 삭제하지 않고 언트래킹하기

git rm --cached <file_path>

다른 방법:

git rm --cached -r <directory_path>

트래킹되지 않은 파일/디렉토리를 실제로 삭제하기 전에 어떤 파일/디렉토리가 삭제되는지 테스트 해보기

git clean -n

트래킹되지 않은 파일들 강제로 삭제하기

git clean -f

트래킹되지 않은 디렉토리 강제로 삭제하기

git clean -f -d

다른 방법:

git clean -df

모든 서브 모듈 업데이트하기

git submodule foreach git pull

다른 방법:

git submodule update --init --recursive
git submodule update --remote

현재 브랜치에서 아직 마스터에 머지되지 않은 모든 커밋들 보기

git cherry -v master

다른 방법:

git cherry -v master <branch-to-be-merged>

브랜치명 수정하기

git branch -m <new-branch-name>

다른 방법:

git branch -m [<old-branch-name>] <new-branch-name>

'feature' 브랜치를 마스터에 리베이스한 후 마스터에 머지하기

git rebase master feature && git checkout master && git merge -

마스터 브랜치 아카이브

git archive master --format=zip --output=master.zip

커밋 메시지는 변경하지 않고 이전 커밋 변경하기

git add --all && git commit --amend --no-edit

원격지에서 삭제된 원격 브랜치 레퍼런스 제거하기

git fetch -p

다른 방법:

git remote prune origin

첫 리비전의 커밋 해시값 가져오기

 git rev-list --reverse HEAD | head -1

다른 방법:

git rev-list --max-parents=0 HEAD
git log --pretty=oneline | tail -1 | cut -c 1-40
git log --pretty=oneline --reverse | head -1 | cut -c 1-40

버전 트리 시각화

git log --pretty=oneline --graph --decorate --all

다른 방법:

gitk --all

트래킹된 하위폴더를 gh-pages 브랜치로 배포하기

git subtree push --prefix subfolder_name origin gh-pages

subtree를 사용해 저장소에 프로젝트 추가하기

git subtree add --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master

subtree를 사용해 관련된 프로젝트의 최신 변경사항을 저장소로 가져오기

git subtree pull --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master

브랜치를 히스토리와 함께 파일로 추출하기

git bundle create <file><branch-name>

번들 가져오기

git clone repo.bundle <repo-dir> -b <branch-name>

현재 브랜치명 가져오기

git rev-parse --abbrev-ref HEAD

커밋시 파일 무시하기 (예를 들어, Changelog 파일)

git update-index --assume-unchanged Changelog; git commit -a; git update-index --no-assume-unchanged Changelog

리베이스 전에 변경사항 스태시하기

git rebase --autostash

ID로 풀 리퀘스트를 로컬 저장소로 가져오기

git fetch origin pull/<id>/head:<branch-name>

다른 방법:

git pull origin pull/<id>/head:<branch-name>

현재 브랜치의 가장 최근 태그 보기

git describe --tags --abbrev=0

diff 워드 단위로 보기

git diff --word-diff

diff 도구를 사용해 변경사항 보기

git difftool -t <commit1><commit2><path>

트래킹된 파일의 변경사항 무시하기

git update-index --assume-unchanged <file_name>

assume-unchanged 되돌리기

git update-index --no-assume-unchanged <file_name>

.gitignore에 명시된 파일들 삭제하기

git clean -X -f

삭제된 파일 복구하기

git checkout <deleting_commit>^ -- <file_path>

특정 커밋으로의 파일로 복구하기

git checkout <commit-ish> -- <file_path>

pull시 머지하는 대신 항상 리베이스 하기

git config --global pull.rebase true

다른 방법:

#git < 1.7.9
git config --global branch.autosetuprebase always

모든 별칭과 설정값들 나열하기

git config --list

대소문자 구별 활성화

git config --global core.ignorecase false

커스텀 에디터 추가하기

git config --global core.editor '$EDITOR'

오타 자동 수정 활성화

git config --global help.autocorrect 1

변경사항이 어떤 릴리즈에 속하는지 확인하기

git name-rev --name-only <SHA-1>

명령어 테스트 해보기 (dry-run 플래그를 지원하는 모든 명령어에서 가능)

git clean -fd --dry-run

커밋이 이전 커밋의 수정 버전임을 표시하기

git commit --fixup <SHA-1>

fixup 커밋을 일반 커밋으로 스쿼시하기

git rebase -i --autosquash

커밋시 스테이징된 파일들 스킵하기

git commit --only <file_path>

대화형으로 스테이징하기

git add -i

무시된 파일들 나열하기

git check-ignore *

무시된 파일들 상태 출력

git status --ignored

Branch2에는 없고 Branch1에만 있는 커밋들 나열하기

git log Branch1 ^Branch2

마지막 n개의 커밋 나열하기

git log -<n>

다른 방법:

git log -n <n>

이전에 충돌을 해결했던 방법을 기록하고 재사용하기

git config --global rerere.enabled 1

모든 충돌된 파일들 에디터로 열기

git diff --name-only | uniq | xargs $EDITOR

unpacked 오브젝트의 갯수와 디스크 사용량 보기

git count-objects --human-readable

오브젝트 데이터베이스에서 도달할 수 없는 오브젝트들 제거하기

git gc --prune=now --aggressive

gitweb으로 워킹 디렉토리 탐색하기

git instaweb [--local] [--httpd=<httpd>] [--port=<port>] [--browser=<browser>]

커밋 로그에서 GPG 시그니쳐 보기

git log --show-signature

글로벌 설정에서 엔트리 제거하기

git config --global --unset <entry-name>

히스토리가 없는 새로운 브랜치로 체크아웃하기

git checkout --orphan <branch_name>

다른 브랜치에서 파일내용 가져오기

git show <branch_name>:<file_name>

루트 커밋과 머지 커밋만 나열하기

git log --first-parent

대화형 리베이스로 이전 두 커밋 수정하기

git rebase --interactive HEAD~2

작업중인 브랜치들 모두 나열하기

git checkout master && git branch --no-merged

이진 탐색으로 좋은/안좋은 커밋 검색하기

git bisect start # Search start 
git bisect bad # Set point to bad commit 
git bisect good v2.6.13-rc2 # Set point to good commit|tag 
git bisect bad # Say current state is bad 
git bisect good # Say current state is good 
git bisect reset # Finish search 

pre-commit과 commit-msg 깃 후킹 우회하기

git commit --no-verify

특정 파일에 대한 커밋과 변경사항 나열하기 (이름이 바뀐 파일도 추적)

git log --follow -p -- <file_path>

단일 브랜치 클론

git clone -b <branch-name> --single-branch https://github.com/user/repo.git

새로운 브랜치 생성과 동시에 스위칭

git checkout -b <branch-name>

다른 방법:

git branch <branch-name>&& git checkout <branch-name>

커밋시 파일 모드 변경 무시

git config core.fileMode false

Git 터미널 색상 출력 비활성화

git config --global color.ui false

특정 명령어에 대한 색상 설정 지정하기

git config --global <specific command e.g branch, diff><true, false or always>

모든 로컬 브랜치를 최근 커밋 날짜를 기준으로 정렬해 나열하기

git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/

트래킹된 파일에서 패턴(정규식이나 문자열)에 매칭되는 라인 검색

git grep --heading --line-number 'foo bar'

저장소의 얕은 카피 버전 클론하기

git clone https://github.com/user/repo.git --depth 1

모든 브랜치에서 주어진 텍스트로 커밋 로그 검색하기

git log --all --grep='<given-text>'

브랜치의 첫 커밋 가져오기 (마스터 브랜치로부터 시작된)

git log master..<branch-name> --oneline | tail -1

스테이징된 파일들 언스테이징하기

git reset HEAD <file-name>

원격 저장소에 강제 푸시하기

git push -f <remote-name><branch-name>

저장소명 추가하기

git remote add <remote-nickname><remote-url>

주어진 파일의 각 라인별 author, 시간 그리고 최종 리비전명 보기

git blame <file-name>

Author와 제목으로 커밋 그룹핑하기

git shortlog

다른 사람이 작업한 내용을 덮어쓰지 않고 강제 푸시하기

git push --force-with-lease <remote-name><branch-name>

특정 author가 기여한 라인수 보기

git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | gawk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s removed lines: %s total lines: %s", add, subs, loc }' -

다른 방법:

git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | awk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s, removed lines: %s, total lines: %s", add, subs, loc }' - # on Mac OSX

Revert: 머지 복구하기

git revert -m 1 <commit-ish>

특정 브랜치의 커밋 수 출력하기

git rev-list --count <branch-name>

별칭: git undo

git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'

오브젝트에 노트(메모) 추가하기

git notes add -m 'Note on the previous commit....'

모든 깃 노트 보기

git log --show-notes='*'

다른 저장소에 있는 커밋 적용하기

git --git-dir=<source-dir>/.git format-patch -k -1 --stdout <SHA1>| git am -3 -k

페치 레퍼런스 지정하기

git fetch origin master:refs/remotes/origin/mymaster

두 브랜치의 공통 조상 커밋 찾기

diff -u <(git rev-list --first-parent BranchA)<(git rev-list --first-parent BranchB)| sed -ne 's/^ //p'| head -1

푸시되지 않은 커밋들 나열하기

git log --branches --not --remotes

다른 방법:

git log @{u}..
git cherry -v

공백 변경사항을 제외한 모든 변경사항 추가하기

git diff --ignore-all-space | git apply --cached

깃 설정 [로컬/글로벌] 수정하기

git config [--global] --edit

특정 구간에서 blame 정보 보기

git blame -L <start>,<end>

Git의 논리적 변수 보기

git var -l |<variable>

패치 파일 미리 포맷팅하기

git format-patch -M upstream..topic

저장소명 가져오기

git rev-parse --show-toplevel

특정 날짜 구간 사이의 커밋 로그 출력하기

git log --since='FEB 1 2017' --until='FEB 14 2017'

로그에서 author 제외하기

git log --perl-regexp --author='^((?!excluded-author-regex).*)

브랜치의 수정사항 요약하기

git request-pull v1.0 https://git.ko.xz/project master:for-linus

원격 저장소의 모든 레퍼런스 나열하기

git ls-remote git://git.kernel.org/pub/scm/git/git.git

트래킹되지 않은 파일들 백업하기

git ls-files --others -i --exclude-standard | xargs zip untracked.zip

모든 git 명령어 별칭 나열하기

git config -l | grep alias| sed 's/^alias\.//g'

다른 방법:

git config -l | grep alias| cut -d '.' -f 2

git 상태 간략하게 보기

git status --short --branch

하루 전의 커밋으로 체크아웃하기

git checkout master@{yesterday}

About

📚 Git 팁 모음집 (https://github.com/git-tips/tips 한국어 버전)

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Git Tips

git tips의 한국어 버전 문서입니다.

English | 中文 | Русский | Tiếng Việt

팁 툴

목차

참고로 모든 명령어는 다음 버전에서 테스트 되었습니다: git version 2.7.4 (Apple Git-66).

20개 내외의 명령어로 Git 사용하기

git help everyday

Git과 함께 제공되는 유용한 가이드라인 보기

git help -g

내용으로 변경사항 검색

git log -S'<a term in the source>'

원격지 동기화 및 로컬 변경사항 덮어쓰기

git fetch origin && git reset --hard origin/master && git clean -f -d

특정 커밋까지의 모든 파일 나열하기

git ls-tree --name-only -r <commit-ish>

첫 번째 커밋 초기화

git update-ref -d HEAD

충돌된 모든 파일 나열하기

git diff --name-only --diff-filter=U

특정 커밋에서 변경된 모든 파일 나열하기

git diff-tree --no-commit-id --name-only -r <commit-ish>

마지막 커밋 이후로 스테이징되지 않은 변경사항 보기

git diff

커밋을 하기 위해 스테이징된 변경사항 보기

git diff --cached

다른 방법:

git diff --staged

스테이징된 변경사항과 스테이징되지 않은 변경사항 모두 보기

git diff HEAD

이미 마스터 브랜치에 머지된 모든 브랜치 나열하기

git branch --merged master

이전 브랜치로 전환하기

git checkout -

다른 방법:

git checkout @{-1}

이미 마스터 브랜치에 머지된 모든 브랜치들 삭제하기

git branch --merged master | grep -v '^\*'| xargs -n 1 git branch -d

다른 방법:

git branch --merged master | grep -v '^\*\| master'| xargs -n 1 git branch -d # will not delete master if master is not checked out

모든 브랜치들 및 그 브랜치들의 업스트림과 마지막 커밋 나열하기

git branch -vv

업스트림 브랜치 설정 (트래킹)

git branch -u origin/mybranch

로컬 브랜치 삭제

git branch -d <local_branchname>

원격 브랜치 삭제

git push origin --delete <remote_branchname>

다른 방법:

git push origin :<remote_branchname>

로컬 태그 삭제

git tag -d <tag-name>

원격 태그 삭제

git push origin :refs/tags/<tag-name>

로컬 변경사항을 헤드의 마지막 내용으로 되돌리기

git checkout -- <file_name>

Revert: 새로운 커밋을 생성하면서 커밋 되돌리기

git revert <commit-ish>

Reset: 커밋 제거 (프라이빗 브랜치에서만 사용하길 권고)

git reset <commit-ish>

이전 커밋 메시지 변경

git commit -v --amend

브랜치의 커밋중 업스트림에 머지되지 않은 커밋 히스토리 보기

git cherry -v master

Author 수정하기

git commit --amend --author='Author Name <email@address.com>'

글로벌 설정에서 변경된 author로 author 재설정하기

git commit --amend --reset-author --no-edit

원격지 URL 변경하기

git remote set-url origin <URL>

모든 원격지 레퍼런스 리스트 나열하기

git remote

다른 방법:

git remote show

모든 로컬 및 원격지 브랜치 나열하기

git branch -a

원격지 브랜치만 나열하기

git branch -r

파일 변경사항의 전체가 아닌 일부만 스테이징하기

git add -p

Git 배시 자동완성 사용하기

curl http://git.io/vfhol >~/.git-completion.bash &&echo'[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash'>>~/.bashrc

2주 전부터 현재까지의 변경사항 보기

git log --no-merges --raw --since='2 weeks ago'

다른 방법:

git whatchanged --since='2 weeks ago'

마스터로부터 포크한 이후에 생성된 모든 커밋 보기

git log --no-merges --stat --reverse master..

cherry-pick을 사용해 브랜치간 커밋 가져오기

git checkout <branch-name>&& git cherry-pick <commit-ish>

해당 커밋 해시를 가지고 있는 브랜치들 검색하기

git branch -a --contains <commit-ish>

다른 방법:

git branch --contains <commit-ish>

Git 명령어 별칭 지정

git config --global alias.<handle><command> git config --global alias.st status

커밋하지 않은 트래킹된 파일들의 상태 저장하기

git stash

다른 방법:

git stash save

스테이징되지 않은 변경사항들의 현재 상태를 트래킹된 파일로 저장하기

git stash -k

다른 방법:

git stash --keep-index
git stash save --keep-index

트래킹되지 않은 파일들까지 모두 포함해 현재 상태 저장하기

git stash -u

다른 방법:

git stash save -u
git stash save --include-untracked

현재 상태를 메시지와 함께 저장하기

git stash save <message>

모든 무시된 파일, 트래킹되지 않은 파일, 트래킹된 파일들의 현재 상태 저장하기

git stash -a

다른 방법:

git stash --all
git stash save --all

저장된 모든 스태시 리스트 나열하기

git stash list

스태시 리스트에서 삭제하지 않고 스태시 적용하기

git stash apply <stash@{n}>

마지막으로 저장된 스태시 상태를 적용하고 스태시 리스트에서 삭제하기

git stash pop

다른 방법:

git stash apply stash@{0} && git stash drop stash@{0}

저장된 모든 스태시 삭제하기

git stash clear

다른 방법:

git stash drop <stash@{n}>

스태시로부터 단일 파일 가져오기

git checkout <stash@{n}> -- <file_path>

다른 방법:

git checkout stash@{0} -- <file_path>

트래킹된 파일들 모두 보기

git ls-files -t

트래킹되지 않은 파일들 모두 보기

git ls-files --others

무시된 파일들 모두 보기

git ls-files --others -i --exclude-standard

저장소에 새로운 워킹 트리 생성하기 (git 2.5)

git worktree add -b <branch-name><path><start-point>

HEAD로부터 새로운 워킹 트리 생성하기

git worktree add --detach <path> HEAD

파일을 삭제하지 않고 언트래킹하기

git rm --cached <file_path>

다른 방법:

git rm --cached -r <directory_path>

트래킹되지 않은 파일/디렉토리를 실제로 삭제하기 전에 어떤 파일/디렉토리가 삭제되는지 테스트 해보기

git clean -n

트래킹되지 않은 파일들 강제로 삭제하기

git clean -f

트래킹되지 않은 디렉토리 강제로 삭제하기

git clean -f -d

다른 방법:

git clean -df

모든 서브 모듈 업데이트하기

git submodule foreach git pull

다른 방법:

git submodule update --init --recursive
git submodule update --remote

현재 브랜치에서 아직 마스터에 머지되지 않은 모든 커밋들 보기

git cherry -v master

다른 방법:

git cherry -v master <branch-to-be-merged>

브랜치명 수정하기

git branch -m <new-branch-name>

다른 방법:

git branch -m [<old-branch-name>] <new-branch-name>

'feature' 브랜치를 마스터에 리베이스한 후 마스터에 머지하기

git rebase master feature && git checkout master && git merge -

마스터 브랜치 아카이브

git archive master --format=zip --output=master.zip

커밋 메시지는 변경하지 않고 이전 커밋 변경하기

git add --all && git commit --amend --no-edit

원격지에서 삭제된 원격 브랜치 레퍼런스 제거하기

git fetch -p

다른 방법:

git remote prune origin

첫 리비전의 커밋 해시값 가져오기

 git rev-list --reverse HEAD | head -1

다른 방법:

git rev-list --max-parents=0 HEAD
git log --pretty=oneline | tail -1 | cut -c 1-40
git log --pretty=oneline --reverse | head -1 | cut -c 1-40

버전 트리 시각화

git log --pretty=oneline --graph --decorate --all

다른 방법:

gitk --all

트래킹된 하위폴더를 gh-pages 브랜치로 배포하기

git subtree push --prefix subfolder_name origin gh-pages

subtree를 사용해 저장소에 프로젝트 추가하기

git subtree add --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master

subtree를 사용해 관련된 프로젝트의 최신 변경사항을 저장소로 가져오기

git subtree pull --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master

브랜치를 히스토리와 함께 파일로 추출하기

git bundle create <file><branch-name>

번들 가져오기

git clone repo.bundle <repo-dir> -b <branch-name>

현재 브랜치명 가져오기

git rev-parse --abbrev-ref HEAD

커밋시 파일 무시하기 (예를 들어, Changelog 파일)

git update-index --assume-unchanged Changelog; git commit -a; git update-index --no-assume-unchanged Changelog

리베이스 전에 변경사항 스태시하기

git rebase --autostash

ID로 풀 리퀘스트를 로컬 저장소로 가져오기

git fetch origin pull/<id>/head:<branch-name>

다른 방법:

git pull origin pull/<id>/head:<branch-name>

현재 브랜치의 가장 최근 태그 보기

git describe --tags --abbrev=0

diff 워드 단위로 보기

git diff --word-diff

diff 도구를 사용해 변경사항 보기

git difftool -t <commit1><commit2><path>

트래킹된 파일의 변경사항 무시하기

git update-index --assume-unchanged <file_name>

assume-unchanged 되돌리기

git update-index --no-assume-unchanged <file_name>

.gitignore에 명시된 파일들 삭제하기

git clean -X -f

삭제된 파일 복구하기

git checkout <deleting_commit>^ -- <file_path>

특정 커밋으로의 파일로 복구하기

git checkout <commit-ish> -- <file_path>

pull시 머지하는 대신 항상 리베이스 하기

git config --global pull.rebase true

다른 방법:

#git < 1.7.9
git config --global branch.autosetuprebase always

모든 별칭과 설정값들 나열하기

git config --list

대소문자 구별 활성화

git config --global core.ignorecase false

커스텀 에디터 추가하기

git config --global core.editor '$EDITOR'

오타 자동 수정 활성화

git config --global help.autocorrect 1

변경사항이 어떤 릴리즈에 속하는지 확인하기

git name-rev --name-only <SHA-1>

명령어 테스트 해보기 (dry-run 플래그를 지원하는 모든 명령어에서 가능)

git clean -fd --dry-run

커밋이 이전 커밋의 수정 버전임을 표시하기

git commit --fixup <SHA-1>

fixup 커밋을 일반 커밋으로 스쿼시하기

git rebase -i --autosquash

커밋시 스테이징된 파일들 스킵하기

git commit --only <file_path>

대화형으로 스테이징하기

git add -i

무시된 파일들 나열하기

git check-ignore *

무시된 파일들 상태 출력

git status --ignored

Branch2에는 없고 Branch1에만 있는 커밋들 나열하기

git log Branch1 ^Branch2

마지막 n개의 커밋 나열하기

git log -<n>

다른 방법:

git log -n <n>

이전에 충돌을 해결했던 방법을 기록하고 재사용하기

git config --global rerere.enabled 1

모든 충돌된 파일들 에디터로 열기

git diff --name-only | uniq | xargs $EDITOR

unpacked 오브젝트의 갯수와 디스크 사용량 보기

git count-objects --human-readable

오브젝트 데이터베이스에서 도달할 수 없는 오브젝트들 제거하기

git gc --prune=now --aggressive

gitweb으로 워킹 디렉토리 탐색하기

git instaweb [--local] [--httpd=<httpd>] [--port=<port>] [--browser=<browser>]

커밋 로그에서 GPG 시그니쳐 보기

git log --show-signature

글로벌 설정에서 엔트리 제거하기

git config --global --unset <entry-name>

히스토리가 없는 새로운 브랜치로 체크아웃하기

git checkout --orphan <branch_name>

다른 브랜치에서 파일내용 가져오기

git show <branch_name>:<file_name>

루트 커밋과 머지 커밋만 나열하기

git log --first-parent

대화형 리베이스로 이전 두 커밋 수정하기

git rebase --interactive HEAD~2

작업중인 브랜치들 모두 나열하기

git checkout master && git branch --no-merged

이진 탐색으로 좋은/안좋은 커밋 검색하기

git bisect start # Search start 
git bisect bad # Set point to bad commit 
git bisect good v2.6.13-rc2 # Set point to good commit|tag 
git bisect bad # Say current state is bad 
git bisect good # Say current state is good 
git bisect reset # Finish search 

pre-commit과 commit-msg 깃 후킹 우회하기

git commit --no-verify

특정 파일에 대한 커밋과 변경사항 나열하기 (이름이 바뀐 파일도 추적)

git log --follow -p -- <file_path>

단일 브랜치 클론

git clone -b <branch-name> --single-branch https://github.com/user/repo.git

새로운 브랜치 생성과 동시에 스위칭

git checkout -b <branch-name>

다른 방법:

git branch <branch-name>&& git checkout <branch-name>

커밋시 파일 모드 변경 무시

git config core.fileMode false

Git 터미널 색상 출력 비활성화

git config --global color.ui false

특정 명령어에 대한 색상 설정 지정하기

git config --global <specific command e.g branch, diff><true, false or always>

모든 로컬 브랜치를 최근 커밋 날짜를 기준으로 정렬해 나열하기

git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/

트래킹된 파일에서 패턴(정규식이나 문자열)에 매칭되는 라인 검색

git grep --heading --line-number 'foo bar'

저장소의 얕은 카피 버전 클론하기

git clone https://github.com/user/repo.git --depth 1

모든 브랜치에서 주어진 텍스트로 커밋 로그 검색하기

git log --all --grep='<given-text>'

브랜치의 첫 커밋 가져오기 (마스터 브랜치로부터 시작된)

git log master..<branch-name> --oneline | tail -1

스테이징된 파일들 언스테이징하기

git reset HEAD <file-name>

원격 저장소에 강제 푸시하기

git push -f <remote-name><branch-name>

저장소명 추가하기

git remote add <remote-nickname><remote-url>

주어진 파일의 각 라인별 author, 시간 그리고 최종 리비전명 보기

git blame <file-name>

Author와 제목으로 커밋 그룹핑하기

git shortlog

다른 사람이 작업한 내용을 덮어쓰지 않고 강제 푸시하기

git push --force-with-lease <remote-name><branch-name>

특정 author가 기여한 라인수 보기

git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | gawk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s removed lines: %s total lines: %s", add, subs, loc }' -

다른 방법:

git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | awk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s, removed lines: %s, total lines: %s", add, subs, loc }' - # on Mac OSX

Revert: 머지 복구하기

git revert -m 1 <commit-ish>

특정 브랜치의 커밋 수 출력하기

git rev-list --count <branch-name>

별칭: git undo

git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'

오브젝트에 노트(메모) 추가하기

git notes add -m 'Note on the previous commit....'

모든 깃 노트 보기

git log --show-notes='*'

다른 저장소에 있는 커밋 적용하기

git --git-dir=<source-dir>/.git format-patch -k -1 --stdout <SHA1>| git am -3 -k

페치 레퍼런스 지정하기

git fetch origin master:refs/remotes/origin/mymaster

두 브랜치의 공통 조상 커밋 찾기

diff -u <(git rev-list --first-parent BranchA)<(git rev-list --first-parent BranchB)| sed -ne 's/^ //p'| head -1

푸시되지 않은 커밋들 나열하기

git log --branches --not --remotes

다른 방법:

git log @{u}..
git cherry -v

공백 변경사항을 제외한 모든 변경사항 추가하기

git diff --ignore-all-space | git apply --cached

깃 설정 [로컬/글로벌] 수정하기

git config [--global] --edit

특정 구간에서 blame 정보 보기

git blame -L <start>,<end>

Git의 논리적 변수 보기

git var -l |<variable>

패치 파일 미리 포맷팅하기

git format-patch -M upstream..topic

저장소명 가져오기

git rev-parse --show-toplevel

특정 날짜 구간 사이의 커밋 로그 출력하기

git log --since='FEB 1 2017' --until='FEB 14 2017'

로그에서 author 제외하기

git log --perl-regexp --author='^((?!excluded-author-regex).*)

브랜치의 수정사항 요약하기

git request-pull v1.0 https://git.ko.xz/project master:for-linus

원격 저장소의 모든 레퍼런스 나열하기

git ls-remote git://git.kernel.org/pub/scm/git/git.git

트래킹되지 않은 파일들 백업하기

git ls-files --others -i --exclude-standard | xargs zip untracked.zip

모든 git 명령어 별칭 나열하기

git config -l | grep alias| sed 's/^alias\.//g'

다른 방법:

git config -l | grep alias| cut -d '.' -f 2

git 상태 간략하게 보기

git status --short --branch

하루 전의 커밋으로 체크아웃하기

git checkout master@{yesterday}

About

📚 Git 팁 모음집 (https://github.com/git-tips/tips 한국어 버전)

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Git Tips

git tips의 한국어 버전 문서입니다.

English | 中文 | Русский | Tiếng Việt

팁 툴

목차

참고로 모든 명령어는 다음 버전에서 테스트 되었습니다: git version 2.7.4 (Apple Git-66).

20개 내외의 명령어로 Git 사용하기

git help everyday

Git과 함께 제공되는 유용한 가이드라인 보기

git help -g

내용으로 변경사항 검색

git log -S'<a term in the source>'

원격지 동기화 및 로컬 변경사항 덮어쓰기

git fetch origin && git reset --hard origin/master && git clean -f -d

특정 커밋까지의 모든 파일 나열하기

git ls-tree --name-only -r <commit-ish>

첫 번째 커밋 초기화

git update-ref -d HEAD

충돌된 모든 파일 나열하기

git diff --name-only --diff-filter=U

특정 커밋에서 변경된 모든 파일 나열하기

git diff-tree --no-commit-id --name-only -r <commit-ish>

마지막 커밋 이후로 스테이징되지 않은 변경사항 보기

git diff

커밋을 하기 위해 스테이징된 변경사항 보기

git diff --cached

다른 방법:

git diff --staged

스테이징된 변경사항과 스테이징되지 않은 변경사항 모두 보기

git diff HEAD

이미 마스터 브랜치에 머지된 모든 브랜치 나열하기

git branch --merged master

이전 브랜치로 전환하기

git checkout -

다른 방법:

git checkout @{-1}

이미 마스터 브랜치에 머지된 모든 브랜치들 삭제하기

git branch --merged master | grep -v '^\*'| xargs -n 1 git branch -d

다른 방법:

git branch --merged master | grep -v '^\*\| master'| xargs -n 1 git branch -d # will not delete master if master is not checked out

모든 브랜치들 및 그 브랜치들의 업스트림과 마지막 커밋 나열하기

git branch -vv

업스트림 브랜치 설정 (트래킹)

git branch -u origin/mybranch

로컬 브랜치 삭제

git branch -d <local_branchname>

원격 브랜치 삭제

git push origin --delete <remote_branchname>

다른 방법:

git push origin :<remote_branchname>

로컬 태그 삭제

git tag -d <tag-name>

원격 태그 삭제

git push origin :refs/tags/<tag-name>

로컬 변경사항을 헤드의 마지막 내용으로 되돌리기

git checkout -- <file_name>

Revert: 새로운 커밋을 생성하면서 커밋 되돌리기

git revert <commit-ish>

Reset: 커밋 제거 (프라이빗 브랜치에서만 사용하길 권고)

git reset <commit-ish>

이전 커밋 메시지 변경

git commit -v --amend

브랜치의 커밋중 업스트림에 머지되지 않은 커밋 히스토리 보기

git cherry -v master

Author 수정하기

git commit --amend --author='Author Name <email@address.com>'

글로벌 설정에서 변경된 author로 author 재설정하기

git commit --amend --reset-author --no-edit

원격지 URL 변경하기

git remote set-url origin <URL>

모든 원격지 레퍼런스 리스트 나열하기

git remote

다른 방법:

git remote show

모든 로컬 및 원격지 브랜치 나열하기

git branch -a

원격지 브랜치만 나열하기

git branch -r

파일 변경사항의 전체가 아닌 일부만 스테이징하기

git add -p

Git 배시 자동완성 사용하기

curl http://git.io/vfhol >~/.git-completion.bash &&echo'[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash'>>~/.bashrc

2주 전부터 현재까지의 변경사항 보기

git log --no-merges --raw --since='2 weeks ago'

다른 방법:

git whatchanged --since='2 weeks ago'

마스터로부터 포크한 이후에 생성된 모든 커밋 보기

git log --no-merges --stat --reverse master..

cherry-pick을 사용해 브랜치간 커밋 가져오기

git checkout <branch-name>&& git cherry-pick <commit-ish>

해당 커밋 해시를 가지고 있는 브랜치들 검색하기

git branch -a --contains <commit-ish>

다른 방법:

git branch --contains <commit-ish>

Git 명령어 별칭 지정

git config --global alias.<handle><command> git config --global alias.st status

커밋하지 않은 트래킹된 파일들의 상태 저장하기

git stash

다른 방법:

git stash save

스테이징되지 않은 변경사항들의 현재 상태를 트래킹된 파일로 저장하기

git stash -k

다른 방법:

git stash --keep-index
git stash save --keep-index

트래킹되지 않은 파일들까지 모두 포함해 현재 상태 저장하기

git stash -u

다른 방법:

git stash save -u
git stash save --include-untracked

현재 상태를 메시지와 함께 저장하기

git stash save <message>

모든 무시된 파일, 트래킹되지 않은 파일, 트래킹된 파일들의 현재 상태 저장하기

git stash -a

다른 방법:

git stash --all
git stash save --all

저장된 모든 스태시 리스트 나열하기

git stash list

스태시 리스트에서 삭제하지 않고 스태시 적용하기

git stash apply <stash@{n}>

마지막으로 저장된 스태시 상태를 적용하고 스태시 리스트에서 삭제하기

git stash pop

다른 방법:

git stash apply stash@{0} && git stash drop stash@{0}

저장된 모든 스태시 삭제하기

git stash clear

다른 방법:

git stash drop <stash@{n}>

스태시로부터 단일 파일 가져오기

git checkout <stash@{n}> -- <file_path>

다른 방법:

git checkout stash@{0} -- <file_path>

트래킹된 파일들 모두 보기

git ls-files -t

트래킹되지 않은 파일들 모두 보기

git ls-files --others

무시된 파일들 모두 보기

git ls-files --others -i --exclude-standard

저장소에 새로운 워킹 트리 생성하기 (git 2.5)

git worktree add -b <branch-name><path><start-point>

HEAD로부터 새로운 워킹 트리 생성하기

git worktree add --detach <path> HEAD

파일을 삭제하지 않고 언트래킹하기

git rm --cached <file_path>

다른 방법:

git rm --cached -r <directory_path>

트래킹되지 않은 파일/디렉토리를 실제로 삭제하기 전에 어떤 파일/디렉토리가 삭제되는지 테스트 해보기

git clean -n

트래킹되지 않은 파일들 강제로 삭제하기

git clean -f

트래킹되지 않은 디렉토리 강제로 삭제하기

git clean -f -d

다른 방법:

git clean -df

모든 서브 모듈 업데이트하기

git submodule foreach git pull

다른 방법:

git submodule update --init --recursive
git submodule update --remote

현재 브랜치에서 아직 마스터에 머지되지 않은 모든 커밋들 보기

git cherry -v master

다른 방법:

git cherry -v master <branch-to-be-merged>

브랜치명 수정하기

git branch -m <new-branch-name>

다른 방법:

git branch -m [<old-branch-name>] <new-branch-name>

'feature' 브랜치를 마스터에 리베이스한 후 마스터에 머지하기

git rebase master feature && git checkout master && git merge -

마스터 브랜치 아카이브

git archive master --format=zip --output=master.zip

커밋 메시지는 변경하지 않고 이전 커밋 변경하기

git add --all && git commit --amend --no-edit

원격지에서 삭제된 원격 브랜치 레퍼런스 제거하기

git fetch -p

다른 방법:

git remote prune origin

첫 리비전의 커밋 해시값 가져오기

 git rev-list --reverse HEAD | head -1

다른 방법:

git rev-list --max-parents=0 HEAD
git log --pretty=oneline | tail -1 | cut -c 1-40
git log --pretty=oneline --reverse | head -1 | cut -c 1-40

버전 트리 시각화

git log --pretty=oneline --graph --decorate --all

다른 방법:

gitk --all

트래킹된 하위폴더를 gh-pages 브랜치로 배포하기

git subtree push --prefix subfolder_name origin gh-pages

subtree를 사용해 저장소에 프로젝트 추가하기

git subtree add --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master

subtree를 사용해 관련된 프로젝트의 최신 변경사항을 저장소로 가져오기

git subtree pull --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master

브랜치를 히스토리와 함께 파일로 추출하기

git bundle create <file><branch-name>

번들 가져오기

git clone repo.bundle <repo-dir> -b <branch-name>

현재 브랜치명 가져오기

git rev-parse --abbrev-ref HEAD

커밋시 파일 무시하기 (예를 들어, Changelog 파일)

git update-index --assume-unchanged Changelog; git commit -a; git update-index --no-assume-unchanged Changelog

리베이스 전에 변경사항 스태시하기

git rebase --autostash

ID로 풀 리퀘스트를 로컬 저장소로 가져오기

git fetch origin pull/<id>/head:<branch-name>

다른 방법:

git pull origin pull/<id>/head:<branch-name>

현재 브랜치의 가장 최근 태그 보기

git describe --tags --abbrev=0

diff 워드 단위로 보기

git diff --word-diff

diff 도구를 사용해 변경사항 보기

git difftool -t <commit1><commit2><path>

트래킹된 파일의 변경사항 무시하기

git update-index --assume-unchanged <file_name>

assume-unchanged 되돌리기

git update-index --no-assume-unchanged <file_name>

.gitignore에 명시된 파일들 삭제하기

git clean -X -f

삭제된 파일 복구하기

git checkout <deleting_commit>^ -- <file_path>

특정 커밋으로의 파일로 복구하기

git checkout <commit-ish> -- <file_path>

pull시 머지하는 대신 항상 리베이스 하기

git config --global pull.rebase true

다른 방법:

#git < 1.7.9
git config --global branch.autosetuprebase always

모든 별칭과 설정값들 나열하기

git config --list

대소문자 구별 활성화

git config --global core.ignorecase false

커스텀 에디터 추가하기

git config --global core.editor '$EDITOR'

오타 자동 수정 활성화

git config --global help.autocorrect 1

변경사항이 어떤 릴리즈에 속하는지 확인하기

git name-rev --name-only <SHA-1>

명령어 테스트 해보기 (dry-run 플래그를 지원하는 모든 명령어에서 가능)

git clean -fd --dry-run

커밋이 이전 커밋의 수정 버전임을 표시하기

git commit --fixup <SHA-1>

fixup 커밋을 일반 커밋으로 스쿼시하기

git rebase -i --autosquash

커밋시 스테이징된 파일들 스킵하기

git commit --only <file_path>

대화형으로 스테이징하기

git add -i

무시된 파일들 나열하기

git check-ignore *

무시된 파일들 상태 출력

git status --ignored

Branch2에는 없고 Branch1에만 있는 커밋들 나열하기

git log Branch1 ^Branch2

마지막 n개의 커밋 나열하기

git log -<n>

다른 방법:

git log -n <n>

이전에 충돌을 해결했던 방법을 기록하고 재사용하기

git config --global rerere.enabled 1

모든 충돌된 파일들 에디터로 열기

git diff --name-only | uniq | xargs $EDITOR

unpacked 오브젝트의 갯수와 디스크 사용량 보기

git count-objects --human-readable

오브젝트 데이터베이스에서 도달할 수 없는 오브젝트들 제거하기

git gc --prune=now --aggressive

gitweb으로 워킹 디렉토리 탐색하기

git instaweb [--local] [--httpd=<httpd>] [--port=<port>] [--browser=<browser>]

커밋 로그에서 GPG 시그니쳐 보기

git log --show-signature

글로벌 설정에서 엔트리 제거하기

git config --global --unset <entry-name>

히스토리가 없는 새로운 브랜치로 체크아웃하기

git checkout --orphan <branch_name>

다른 브랜치에서 파일내용 가져오기

git show <branch_name>:<file_name>

루트 커밋과 머지 커밋만 나열하기

git log --first-parent

대화형 리베이스로 이전 두 커밋 수정하기

git rebase --interactive HEAD~2

작업중인 브랜치들 모두 나열하기

git checkout master && git branch --no-merged

이진 탐색으로 좋은/안좋은 커밋 검색하기

git bisect start # Search start 
git bisect bad # Set point to bad commit 
git bisect good v2.6.13-rc2 # Set point to good commit|tag 
git bisect bad # Say current state is bad 
git bisect good # Say current state is good 
git bisect reset # Finish search 

pre-commit과 commit-msg 깃 후킹 우회하기

git commit --no-verify

특정 파일에 대한 커밋과 변경사항 나열하기 (이름이 바뀐 파일도 추적)

git log --follow -p -- <file_path>

단일 브랜치 클론

git clone -b <branch-name> --single-branch https://github.com/user/repo.git

새로운 브랜치 생성과 동시에 스위칭

git checkout -b <branch-name>

다른 방법:

git branch <branch-name>&& git checkout <branch-name>

커밋시 파일 모드 변경 무시

git config core.fileMode false

Git 터미널 색상 출력 비활성화

git config --global color.ui false

특정 명령어에 대한 색상 설정 지정하기

git config --global <specific command e.g branch, diff><true, false or always>

모든 로컬 브랜치를 최근 커밋 날짜를 기준으로 정렬해 나열하기

git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/

트래킹된 파일에서 패턴(정규식이나 문자열)에 매칭되는 라인 검색

git grep --heading --line-number 'foo bar'

저장소의 얕은 카피 버전 클론하기

git clone https://github.com/user/repo.git --depth 1

모든 브랜치에서 주어진 텍스트로 커밋 로그 검색하기

git log --all --grep='<given-text>'

브랜치의 첫 커밋 가져오기 (마스터 브랜치로부터 시작된)

git log master..<branch-name> --oneline | tail -1

스테이징된 파일들 언스테이징하기

git reset HEAD <file-name>

원격 저장소에 강제 푸시하기

git push -f <remote-name><branch-name>

저장소명 추가하기

git remote add <remote-nickname><remote-url>

주어진 파일의 각 라인별 author, 시간 그리고 최종 리비전명 보기

git blame <file-name>

Author와 제목으로 커밋 그룹핑하기

git shortlog

다른 사람이 작업한 내용을 덮어쓰지 않고 강제 푸시하기

git push --force-with-lease <remote-name><branch-name>

특정 author가 기여한 라인수 보기

git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | gawk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s removed lines: %s total lines: %s", add, subs, loc }' -

다른 방법:

git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | awk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s, removed lines: %s, total lines: %s", add, subs, loc }' - # on Mac OSX

Revert: 머지 복구하기

git revert -m 1 <commit-ish>

특정 브랜치의 커밋 수 출력하기

git rev-list --count <branch-name>

별칭: git undo

git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'

오브젝트에 노트(메모) 추가하기

git notes add -m 'Note on the previous commit....'

모든 깃 노트 보기

git log --show-notes='*'

다른 저장소에 있는 커밋 적용하기

git --git-dir=<source-dir>/.git format-patch -k -1 --stdout <SHA1>| git am -3 -k

페치 레퍼런스 지정하기

git fetch origin master:refs/remotes/origin/mymaster

두 브랜치의 공통 조상 커밋 찾기

diff -u <(git rev-list --first-parent BranchA)<(git rev-list --first-parent BranchB)| sed -ne 's/^ //p'| head -1

푸시되지 않은 커밋들 나열하기

git log --branches --not --remotes

다른 방법:

git log @{u}..
git cherry -v

공백 변경사항을 제외한 모든 변경사항 추가하기

git diff --ignore-all-space | git apply --cached

깃 설정 [로컬/글로벌] 수정하기

git config [--global] --edit

특정 구간에서 blame 정보 보기

git blame -L <start>,<end>

Git의 논리적 변수 보기

git var -l |<variable>

패치 파일 미리 포맷팅하기

git format-patch -M upstream..topic

저장소명 가져오기

git rev-parse --show-toplevel

특정 날짜 구간 사이의 커밋 로그 출력하기

git log --since='FEB 1 2017' --until='FEB 14 2017'

로그에서 author 제외하기

git log --perl-regexp --author='^((?!excluded-author-regex).*)

브랜치의 수정사항 요약하기

git request-pull v1.0 https://git.ko.xz/project master:for-linus

원격 저장소의 모든 레퍼런스 나열하기

git ls-remote git://git.kernel.org/pub/scm/git/git.git

트래킹되지 않은 파일들 백업하기

git ls-files --others -i --exclude-standard | xargs zip untracked.zip

모든 git 명령어 별칭 나열하기

git config -l | grep alias| sed 's/^alias\.//g'

다른 방법:

git config -l | grep alias| cut -d '.' -f 2

git 상태 간략하게 보기

git status --short --branch

하루 전의 커밋으로 체크아웃하기

git checkout master@{yesterday}

About

📚 Git 팁 모음집 (https://github.com/git-tips/tips 한국어 버전)

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Git Tips

git tips의 한국어 버전 문서입니다.

English | 中文 | Русский | Tiếng Việt

팁 툴

목차

참고로 모든 명령어는 다음 버전에서 테스트 되었습니다: git version 2.7.4 (Apple Git-66).

20개 내외의 명령어로 Git 사용하기

git help everyday

Git과 함께 제공되는 유용한 가이드라인 보기

git help -g

내용으로 변경사항 검색

git log -S'<a term in the source>'

원격지 동기화 및 로컬 변경사항 덮어쓰기

git fetch origin && git reset --hard origin/master && git clean -f -d

특정 커밋까지의 모든 파일 나열하기

git ls-tree --name-only -r <commit-ish>

첫 번째 커밋 초기화

git update-ref -d HEAD

충돌된 모든 파일 나열하기

git diff --name-only --diff-filter=U

특정 커밋에서 변경된 모든 파일 나열하기

git diff-tree --no-commit-id --name-only -r <commit-ish>

마지막 커밋 이후로 스테이징되지 않은 변경사항 보기

git diff

커밋을 하기 위해 스테이징된 변경사항 보기

git diff --cached

다른 방법:

git diff --staged

스테이징된 변경사항과 스테이징되지 않은 변경사항 모두 보기

git diff HEAD

이미 마스터 브랜치에 머지된 모든 브랜치 나열하기

git branch --merged master

이전 브랜치로 전환하기

git checkout -

다른 방법:

git checkout @{-1}

이미 마스터 브랜치에 머지된 모든 브랜치들 삭제하기

git branch --merged master | grep -v '^\*'| xargs -n 1 git branch -d

다른 방법:

git branch --merged master | grep -v '^\*\| master'| xargs -n 1 git branch -d # will not delete master if master is not checked out

모든 브랜치들 및 그 브랜치들의 업스트림과 마지막 커밋 나열하기

git branch -vv

업스트림 브랜치 설정 (트래킹)

git branch -u origin/mybranch

로컬 브랜치 삭제

git branch -d <local_branchname>

원격 브랜치 삭제

git push origin --delete <remote_branchname>

다른 방법:

git push origin :<remote_branchname>

로컬 태그 삭제

git tag -d <tag-name>

원격 태그 삭제

git push origin :refs/tags/<tag-name>

로컬 변경사항을 헤드의 마지막 내용으로 되돌리기

git checkout -- <file_name>

Revert: 새로운 커밋을 생성하면서 커밋 되돌리기

git revert <commit-ish>

Reset: 커밋 제거 (프라이빗 브랜치에서만 사용하길 권고)

git reset <commit-ish>

이전 커밋 메시지 변경

git commit -v --amend

브랜치의 커밋중 업스트림에 머지되지 않은 커밋 히스토리 보기

git cherry -v master

Author 수정하기

git commit --amend --author='Author Name <email@address.com>'

글로벌 설정에서 변경된 author로 author 재설정하기

git commit --amend --reset-author --no-edit

원격지 URL 변경하기

git remote set-url origin <URL>

모든 원격지 레퍼런스 리스트 나열하기

git remote

다른 방법:

git remote show

모든 로컬 및 원격지 브랜치 나열하기

git branch -a

원격지 브랜치만 나열하기

git branch -r

파일 변경사항의 전체가 아닌 일부만 스테이징하기

git add -p

Git 배시 자동완성 사용하기

curl http://git.io/vfhol >~/.git-completion.bash &&echo'[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash'>>~/.bashrc

2주 전부터 현재까지의 변경사항 보기

git log --no-merges --raw --since='2 weeks ago'

다른 방법:

git whatchanged --since='2 weeks ago'

마스터로부터 포크한 이후에 생성된 모든 커밋 보기

git log --no-merges --stat --reverse master..

cherry-pick을 사용해 브랜치간 커밋 가져오기

git checkout <branch-name>&& git cherry-pick <commit-ish>

해당 커밋 해시를 가지고 있는 브랜치들 검색하기

git branch -a --contains <commit-ish>

다른 방법:

git branch --contains <commit-ish>

Git 명령어 별칭 지정

git config --global alias.<handle><command> git config --global alias.st status

커밋하지 않은 트래킹된 파일들의 상태 저장하기

git stash

다른 방법:

git stash save

스테이징되지 않은 변경사항들의 현재 상태를 트래킹된 파일로 저장하기

git stash -k

다른 방법:

git stash --keep-index
git stash save --keep-index

트래킹되지 않은 파일들까지 모두 포함해 현재 상태 저장하기

git stash -u

다른 방법:

git stash save -u
git stash save --include-untracked

현재 상태를 메시지와 함께 저장하기

git stash save <message>

모든 무시된 파일, 트래킹되지 않은 파일, 트래킹된 파일들의 현재 상태 저장하기

git stash -a

다른 방법:

git stash --all
git stash save --all

저장된 모든 스태시 리스트 나열하기

git stash list

스태시 리스트에서 삭제하지 않고 스태시 적용하기

git stash apply <stash@{n}>

마지막으로 저장된 스태시 상태를 적용하고 스태시 리스트에서 삭제하기

git stash pop

다른 방법:

git stash apply stash@{0} && git stash drop stash@{0}

저장된 모든 스태시 삭제하기

git stash clear

다른 방법:

git stash drop <stash@{n}>

스태시로부터 단일 파일 가져오기

git checkout <stash@{n}> -- <file_path>

다른 방법:

git checkout stash@{0} -- <file_path>

트래킹된 파일들 모두 보기

git ls-files -t

트래킹되지 않은 파일들 모두 보기

git ls-files --others

무시된 파일들 모두 보기

git ls-files --others -i --exclude-standard

저장소에 새로운 워킹 트리 생성하기 (git 2.5)

git worktree add -b <branch-name><path><start-point>

HEAD로부터 새로운 워킹 트리 생성하기

git worktree add --detach <path> HEAD

파일을 삭제하지 않고 언트래킹하기

git rm --cached <file_path>

다른 방법:

git rm --cached -r <directory_path>

트래킹되지 않은 파일/디렉토리를 실제로 삭제하기 전에 어떤 파일/디렉토리가 삭제되는지 테스트 해보기

git clean -n

트래킹되지 않은 파일들 강제로 삭제하기

git clean -f

트래킹되지 않은 디렉토리 강제로 삭제하기

git clean -f -d

다른 방법:

git clean -df

모든 서브 모듈 업데이트하기

git submodule foreach git pull

다른 방법:

git submodule update --init --recursive
git submodule update --remote

현재 브랜치에서 아직 마스터에 머지되지 않은 모든 커밋들 보기

git cherry -v master

다른 방법:

git cherry -v master <branch-to-be-merged>

브랜치명 수정하기

git branch -m <new-branch-name>

다른 방법:

git branch -m [<old-branch-name>] <new-branch-name>

'feature' 브랜치를 마스터에 리베이스한 후 마스터에 머지하기

git rebase master feature && git checkout master && git merge -

마스터 브랜치 아카이브

git archive master --format=zip --output=master.zip

커밋 메시지는 변경하지 않고 이전 커밋 변경하기

git add --all && git commit --amend --no-edit

원격지에서 삭제된 원격 브랜치 레퍼런스 제거하기

git fetch -p

다른 방법:

git remote prune origin

첫 리비전의 커밋 해시값 가져오기

 git rev-list --reverse HEAD | head -1

다른 방법:

git rev-list --max-parents=0 HEAD
git log --pretty=oneline | tail -1 | cut -c 1-40
git log --pretty=oneline --reverse | head -1 | cut -c 1-40

버전 트리 시각화

git log --pretty=oneline --graph --decorate --all

다른 방법:

gitk --all

트래킹된 하위폴더를 gh-pages 브랜치로 배포하기

git subtree push --prefix subfolder_name origin gh-pages

subtree를 사용해 저장소에 프로젝트 추가하기

git subtree add --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master

subtree를 사용해 관련된 프로젝트의 최신 변경사항을 저장소로 가져오기

git subtree pull --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master

브랜치를 히스토리와 함께 파일로 추출하기

git bundle create <file><branch-name>

번들 가져오기

git clone repo.bundle <repo-dir> -b <branch-name>

현재 브랜치명 가져오기

git rev-parse --abbrev-ref HEAD

커밋시 파일 무시하기 (예를 들어, Changelog 파일)

git update-index --assume-unchanged Changelog; git commit -a; git update-index --no-assume-unchanged Changelog

리베이스 전에 변경사항 스태시하기

git rebase --autostash

ID로 풀 리퀘스트를 로컬 저장소로 가져오기

git fetch origin pull/<id>/head:<branch-name>

다른 방법:

git pull origin pull/<id>/head:<branch-name>

현재 브랜치의 가장 최근 태그 보기

git describe --tags --abbrev=0

diff 워드 단위로 보기

git diff --word-diff

diff 도구를 사용해 변경사항 보기

git difftool -t <commit1><commit2><path>

트래킹된 파일의 변경사항 무시하기

git update-index --assume-unchanged <file_name>

assume-unchanged 되돌리기

git update-index --no-assume-unchanged <file_name>

.gitignore에 명시된 파일들 삭제하기

git clean -X -f

삭제된 파일 복구하기

git checkout <deleting_commit>^ -- <file_path>

특정 커밋으로의 파일로 복구하기

git checkout <commit-ish> -- <file_path>

pull시 머지하는 대신 항상 리베이스 하기

git config --global pull.rebase true

다른 방법:

#git < 1.7.9
git config --global branch.autosetuprebase always

모든 별칭과 설정값들 나열하기

git config --list

대소문자 구별 활성화

git config --global core.ignorecase false

커스텀 에디터 추가하기

git config --global core.editor '$EDITOR'

오타 자동 수정 활성화

git config --global help.autocorrect 1

변경사항이 어떤 릴리즈에 속하는지 확인하기

git name-rev --name-only <SHA-1>

명령어 테스트 해보기 (dry-run 플래그를 지원하는 모든 명령어에서 가능)

git clean -fd --dry-run

커밋이 이전 커밋의 수정 버전임을 표시하기

git commit --fixup <SHA-1>

fixup 커밋을 일반 커밋으로 스쿼시하기

git rebase -i --autosquash

커밋시 스테이징된 파일들 스킵하기

git commit --only <file_path>

대화형으로 스테이징하기

git add -i

무시된 파일들 나열하기

git check-ignore *

무시된 파일들 상태 출력

git status --ignored

Branch2에는 없고 Branch1에만 있는 커밋들 나열하기

git log Branch1 ^Branch2

마지막 n개의 커밋 나열하기

git log -<n>

다른 방법:

git log -n <n>

이전에 충돌을 해결했던 방법을 기록하고 재사용하기

git config --global rerere.enabled 1

모든 충돌된 파일들 에디터로 열기

git diff --name-only | uniq | xargs $EDITOR

unpacked 오브젝트의 갯수와 디스크 사용량 보기

git count-objects --human-readable

오브젝트 데이터베이스에서 도달할 수 없는 오브젝트들 제거하기

git gc --prune=now --aggressive

gitweb으로 워킹 디렉토리 탐색하기

git instaweb [--local] [--httpd=<httpd>] [--port=<port>] [--browser=<browser>]

커밋 로그에서 GPG 시그니쳐 보기

git log --show-signature

글로벌 설정에서 엔트리 제거하기

git config --global --unset <entry-name>

히스토리가 없는 새로운 브랜치로 체크아웃하기

git checkout --orphan <branch_name>

다른 브랜치에서 파일내용 가져오기

git show <branch_name>:<file_name>

루트 커밋과 머지 커밋만 나열하기

git log --first-parent

대화형 리베이스로 이전 두 커밋 수정하기

git rebase --interactive HEAD~2

작업중인 브랜치들 모두 나열하기

git checkout master && git branch --no-merged

이진 탐색으로 좋은/안좋은 커밋 검색하기

git bisect start # Search start 
git bisect bad # Set point to bad commit 
git bisect good v2.6.13-rc2 # Set point to good commit|tag 
git bisect bad # Say current state is bad 
git bisect good # Say current state is good 
git bisect reset # Finish search 

pre-commit과 commit-msg 깃 후킹 우회하기

git commit --no-verify

특정 파일에 대한 커밋과 변경사항 나열하기 (이름이 바뀐 파일도 추적)

git log --follow -p -- <file_path>

단일 브랜치 클론

git clone -b <branch-name> --single-branch https://github.com/user/repo.git

새로운 브랜치 생성과 동시에 스위칭

git checkout -b <branch-name>

다른 방법:

git branch <branch-name>&& git checkout <branch-name>

커밋시 파일 모드 변경 무시

git config core.fileMode false

Git 터미널 색상 출력 비활성화

git config --global color.ui false

특정 명령어에 대한 색상 설정 지정하기

git config --global <specific command e.g branch, diff><true, false or always>

모든 로컬 브랜치를 최근 커밋 날짜를 기준으로 정렬해 나열하기

git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/

트래킹된 파일에서 패턴(정규식이나 문자열)에 매칭되는 라인 검색

git grep --heading --line-number 'foo bar'

저장소의 얕은 카피 버전 클론하기

git clone https://github.com/user/repo.git --depth 1

모든 브랜치에서 주어진 텍스트로 커밋 로그 검색하기

git log --all --grep='<given-text>'

브랜치의 첫 커밋 가져오기 (마스터 브랜치로부터 시작된)

git log master..<branch-name> --oneline | tail -1

스테이징된 파일들 언스테이징하기

git reset HEAD <file-name>

원격 저장소에 강제 푸시하기

git push -f <remote-name><branch-name>

저장소명 추가하기

git remote add <remote-nickname><remote-url>

주어진 파일의 각 라인별 author, 시간 그리고 최종 리비전명 보기

git blame <file-name>

Author와 제목으로 커밋 그룹핑하기

git shortlog

다른 사람이 작업한 내용을 덮어쓰지 않고 강제 푸시하기

git push --force-with-lease <remote-name><branch-name>

특정 author가 기여한 라인수 보기

git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | gawk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s removed lines: %s total lines: %s", add, subs, loc }' -

다른 방법:

git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | awk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s, removed lines: %s, total lines: %s", add, subs, loc }' - # on Mac OSX

Revert: 머지 복구하기

git revert -m 1 <commit-ish>

특정 브랜치의 커밋 수 출력하기

git rev-list --count <branch-name>

별칭: git undo

git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'

오브젝트에 노트(메모) 추가하기

git notes add -m 'Note on the previous commit....'

모든 깃 노트 보기

git log --show-notes='*'

다른 저장소에 있는 커밋 적용하기

git --git-dir=<source-dir>/.git format-patch -k -1 --stdout <SHA1>| git am -3 -k

페치 레퍼런스 지정하기

git fetch origin master:refs/remotes/origin/mymaster

두 브랜치의 공통 조상 커밋 찾기

diff -u <(git rev-list --first-parent BranchA)<(git rev-list --first-parent BranchB)| sed -ne 's/^ //p'| head -1

푸시되지 않은 커밋들 나열하기

git log --branches --not --remotes

다른 방법:

git log @{u}..
git cherry -v

공백 변경사항을 제외한 모든 변경사항 추가하기

git diff --ignore-all-space | git apply --cached

깃 설정 [로컬/글로벌] 수정하기

git config [--global] --edit

특정 구간에서 blame 정보 보기

git blame -L <start>,<end>

Git의 논리적 변수 보기

git var -l |<variable>

패치 파일 미리 포맷팅하기

git format-patch -M upstream..topic

저장소명 가져오기

git rev-parse --show-toplevel

특정 날짜 구간 사이의 커밋 로그 출력하기

git log --since='FEB 1 2017' --until='FEB 14 2017'

로그에서 author 제외하기

git log --perl-regexp --author='^((?!excluded-author-regex).*)

브랜치의 수정사항 요약하기

git request-pull v1.0 https://git.ko.xz/project master:for-linus

원격 저장소의 모든 레퍼런스 나열하기

git ls-remote git://git.kernel.org/pub/scm/git/git.git

트래킹되지 않은 파일들 백업하기

git ls-files --others -i --exclude-standard | xargs zip untracked.zip

모든 git 명령어 별칭 나열하기

git config -l | grep alias| sed 's/^alias\.//g'

다른 방법:

git config -l | grep alias| cut -d '.' -f 2

git 상태 간략하게 보기

git status --short --branch

하루 전의 커밋으로 체크아웃하기

git checkout master@{yesterday}

About

📚 Git 팁 모음집 (https://github.com/git-tips/tips 한국어 버전)

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Git Tips

git tips의 한국어 버전 문서입니다.

English | 中文 | Русский | Tiếng Việt

팁 툴

목차

참고로 모든 명령어는 다음 버전에서 테스트 되었습니다: git version 2.7.4 (Apple Git-66).

20개 내외의 명령어로 Git 사용하기

git help everyday

Git과 함께 제공되는 유용한 가이드라인 보기

git help -g

내용으로 변경사항 검색

git log -S'<a term in the source>'

원격지 동기화 및 로컬 변경사항 덮어쓰기

git fetch origin && git reset --hard origin/master && git clean -f -d

특정 커밋까지의 모든 파일 나열하기

git ls-tree --name-only -r <commit-ish>

첫 번째 커밋 초기화

git update-ref -d HEAD

충돌된 모든 파일 나열하기

git diff --name-only --diff-filter=U

특정 커밋에서 변경된 모든 파일 나열하기

git diff-tree --no-commit-id --name-only -r <commit-ish>

마지막 커밋 이후로 스테이징되지 않은 변경사항 보기

git diff

커밋을 하기 위해 스테이징된 변경사항 보기

git diff --cached

다른 방법:

git diff --staged

스테이징된 변경사항과 스테이징되지 않은 변경사항 모두 보기

git diff HEAD

이미 마스터 브랜치에 머지된 모든 브랜치 나열하기

git branch --merged master

이전 브랜치로 전환하기

git checkout -

다른 방법:

git checkout @{-1}

이미 마스터 브랜치에 머지된 모든 브랜치들 삭제하기

git branch --merged master | grep -v '^\*'| xargs -n 1 git branch -d

다른 방법:

git branch --merged master | grep -v '^\*\| master'| xargs -n 1 git branch -d # will not delete master if master is not checked out

모든 브랜치들 및 그 브랜치들의 업스트림과 마지막 커밋 나열하기

git branch -vv

업스트림 브랜치 설정 (트래킹)

git branch -u origin/mybranch

로컬 브랜치 삭제

git branch -d <local_branchname>

원격 브랜치 삭제

git push origin --delete <remote_branchname>

다른 방법:

git push origin :<remote_branchname>

로컬 태그 삭제

git tag -d <tag-name>

원격 태그 삭제

git push origin :refs/tags/<tag-name>

로컬 변경사항을 헤드의 마지막 내용으로 되돌리기

git checkout -- <file_name>

Revert: 새로운 커밋을 생성하면서 커밋 되돌리기

git revert <commit-ish>

Reset: 커밋 제거 (프라이빗 브랜치에서만 사용하길 권고)

git reset <commit-ish>

이전 커밋 메시지 변경

git commit -v --amend

브랜치의 커밋중 업스트림에 머지되지 않은 커밋 히스토리 보기

git cherry -v master

Author 수정하기

git commit --amend --author='Author Name <email@address.com>'

글로벌 설정에서 변경된 author로 author 재설정하기

git commit --amend --reset-author --no-edit

원격지 URL 변경하기

git remote set-url origin <URL>

모든 원격지 레퍼런스 리스트 나열하기

git remote

다른 방법:

git remote show

모든 로컬 및 원격지 브랜치 나열하기

git branch -a

원격지 브랜치만 나열하기

git branch -r

파일 변경사항의 전체가 아닌 일부만 스테이징하기

git add -p

Git 배시 자동완성 사용하기

curl http://git.io/vfhol >~/.git-completion.bash &&echo'[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash'>>~/.bashrc

2주 전부터 현재까지의 변경사항 보기

git log --no-merges --raw --since='2 weeks ago'

다른 방법:

git whatchanged --since='2 weeks ago'

마스터로부터 포크한 이후에 생성된 모든 커밋 보기

git log --no-merges --stat --reverse master..

cherry-pick을 사용해 브랜치간 커밋 가져오기

git checkout <branch-name>&& git cherry-pick <commit-ish>

해당 커밋 해시를 가지고 있는 브랜치들 검색하기

git branch -a --contains <commit-ish>

다른 방법:

git branch --contains <commit-ish>

Git 명령어 별칭 지정

git config --global alias.<handle><command> git config --global alias.st status

커밋하지 않은 트래킹된 파일들의 상태 저장하기

git stash

다른 방법:

git stash save

스테이징되지 않은 변경사항들의 현재 상태를 트래킹된 파일로 저장하기

git stash -k

다른 방법:

git stash --keep-index
git stash save --keep-index

트래킹되지 않은 파일들까지 모두 포함해 현재 상태 저장하기

git stash -u

다른 방법:

git stash save -u
git stash save --include-untracked

현재 상태를 메시지와 함께 저장하기

git stash save <message>

모든 무시된 파일, 트래킹되지 않은 파일, 트래킹된 파일들의 현재 상태 저장하기

git stash -a

다른 방법:

git stash --all
git stash save --all

저장된 모든 스태시 리스트 나열하기

git stash list

스태시 리스트에서 삭제하지 않고 스태시 적용하기

git stash apply <stash@{n}>

마지막으로 저장된 스태시 상태를 적용하고 스태시 리스트에서 삭제하기

git stash pop

다른 방법:

git stash apply stash@{0} && git stash drop stash@{0}

저장된 모든 스태시 삭제하기

git stash clear

다른 방법:

git stash drop <stash@{n}>

스태시로부터 단일 파일 가져오기

git checkout <stash@{n}> -- <file_path>

다른 방법:

git checkout stash@{0} -- <file_path>

트래킹된 파일들 모두 보기

git ls-files -t

트래킹되지 않은 파일들 모두 보기

git ls-files --others

무시된 파일들 모두 보기

git ls-files --others -i --exclude-standard

저장소에 새로운 워킹 트리 생성하기 (git 2.5)

git worktree add -b <branch-name><path><start-point>

HEAD로부터 새로운 워킹 트리 생성하기

git worktree add --detach <path> HEAD

파일을 삭제하지 않고 언트래킹하기

git rm --cached <file_path>

다른 방법:

git rm --cached -r <directory_path>

트래킹되지 않은 파일/디렉토리를 실제로 삭제하기 전에 어떤 파일/디렉토리가 삭제되는지 테스트 해보기

git clean -n

트래킹되지 않은 파일들 강제로 삭제하기

git clean -f

트래킹되지 않은 디렉토리 강제로 삭제하기

git clean -f -d

다른 방법:

git clean -df

모든 서브 모듈 업데이트하기

git submodule foreach git pull

다른 방법:

git submodule update --init --recursive
git submodule update --remote

현재 브랜치에서 아직 마스터에 머지되지 않은 모든 커밋들 보기

git cherry -v master

다른 방법:

git cherry -v master <branch-to-be-merged>

브랜치명 수정하기

git branch -m <new-branch-name>

다른 방법:

git branch -m [<old-branch-name>] <new-branch-name>

'feature' 브랜치를 마스터에 리베이스한 후 마스터에 머지하기

git rebase master feature && git checkout master && git merge -

마스터 브랜치 아카이브

git archive master --format=zip --output=master.zip

커밋 메시지는 변경하지 않고 이전 커밋 변경하기

git add --all && git commit --amend --no-edit

원격지에서 삭제된 원격 브랜치 레퍼런스 제거하기

git fetch -p

다른 방법:

git remote prune origin

첫 리비전의 커밋 해시값 가져오기

 git rev-list --reverse HEAD | head -1

다른 방법:

git rev-list --max-parents=0 HEAD
git log --pretty=oneline | tail -1 | cut -c 1-40
git log --pretty=oneline --reverse | head -1 | cut -c 1-40

버전 트리 시각화

git log --pretty=oneline --graph --decorate --all

다른 방법:

gitk --all

트래킹된 하위폴더를 gh-pages 브랜치로 배포하기

git subtree push --prefix subfolder_name origin gh-pages

subtree를 사용해 저장소에 프로젝트 추가하기

git subtree add --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master

subtree를 사용해 관련된 프로젝트의 최신 변경사항을 저장소로 가져오기

git subtree pull --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master

브랜치를 히스토리와 함께 파일로 추출하기

git bundle create <file><branch-name>

번들 가져오기

git clone repo.bundle <repo-dir> -b <branch-name>

현재 브랜치명 가져오기

git rev-parse --abbrev-ref HEAD

커밋시 파일 무시하기 (예를 들어, Changelog 파일)

git update-index --assume-unchanged Changelog; git commit -a; git update-index --no-assume-unchanged Changelog

리베이스 전에 변경사항 스태시하기

git rebase --autostash

ID로 풀 리퀘스트를 로컬 저장소로 가져오기

git fetch origin pull/<id>/head:<branch-name>

다른 방법:

git pull origin pull/<id>/head:<branch-name>

현재 브랜치의 가장 최근 태그 보기

git describe --tags --abbrev=0

diff 워드 단위로 보기

git diff --word-diff

diff 도구를 사용해 변경사항 보기

git difftool -t <commit1><commit2><path>

트래킹된 파일의 변경사항 무시하기

git update-index --assume-unchanged <file_name>

assume-unchanged 되돌리기

git update-index --no-assume-unchanged <file_name>

.gitignore에 명시된 파일들 삭제하기

git clean -X -f

삭제된 파일 복구하기

git checkout <deleting_commit>^ -- <file_path>

특정 커밋으로의 파일로 복구하기

git checkout <commit-ish> -- <file_path>

pull시 머지하는 대신 항상 리베이스 하기

git config --global pull.rebase true

다른 방법:

#git < 1.7.9
git config --global branch.autosetuprebase always

모든 별칭과 설정값들 나열하기

git config --list

대소문자 구별 활성화

git config --global core.ignorecase false

커스텀 에디터 추가하기

git config --global core.editor '$EDITOR'

오타 자동 수정 활성화

git config --global help.autocorrect 1

변경사항이 어떤 릴리즈에 속하는지 확인하기

git name-rev --name-only <SHA-1>

명령어 테스트 해보기 (dry-run 플래그를 지원하는 모든 명령어에서 가능)

git clean -fd --dry-run

커밋이 이전 커밋의 수정 버전임을 표시하기

git commit --fixup <SHA-1>

fixup 커밋을 일반 커밋으로 스쿼시하기

git rebase -i --autosquash

커밋시 스테이징된 파일들 스킵하기

git commit --only <file_path>

대화형으로 스테이징하기

git add -i

무시된 파일들 나열하기

git check-ignore *

무시된 파일들 상태 출력

git status --ignored

Branch2에는 없고 Branch1에만 있는 커밋들 나열하기

git log Branch1 ^Branch2

마지막 n개의 커밋 나열하기

git log -<n>

다른 방법:

git log -n <n>

이전에 충돌을 해결했던 방법을 기록하고 재사용하기

git config --global rerere.enabled 1

모든 충돌된 파일들 에디터로 열기

git diff --name-only | uniq | xargs $EDITOR

unpacked 오브젝트의 갯수와 디스크 사용량 보기

git count-objects --human-readable

오브젝트 데이터베이스에서 도달할 수 없는 오브젝트들 제거하기

git gc --prune=now --aggressive

gitweb으로 워킹 디렉토리 탐색하기

git instaweb [--local] [--httpd=<httpd>] [--port=<port>] [--browser=<browser>]

커밋 로그에서 GPG 시그니쳐 보기

git log --show-signature

글로벌 설정에서 엔트리 제거하기

git config --global --unset <entry-name>

히스토리가 없는 새로운 브랜치로 체크아웃하기

git checkout --orphan <branch_name>

다른 브랜치에서 파일내용 가져오기

git show <branch_name>:<file_name>

루트 커밋과 머지 커밋만 나열하기

git log --first-parent

대화형 리베이스로 이전 두 커밋 수정하기

git rebase --interactive HEAD~2

작업중인 브랜치들 모두 나열하기

git checkout master && git branch --no-merged

이진 탐색으로 좋은/안좋은 커밋 검색하기

git bisect start # Search start 
git bisect bad # Set point to bad commit 
git bisect good v2.6.13-rc2 # Set point to good commit|tag 
git bisect bad # Say current state is bad 
git bisect good # Say current state is good 
git bisect reset # Finish search 

pre-commit과 commit-msg 깃 후킹 우회하기

git commit --no-verify

특정 파일에 대한 커밋과 변경사항 나열하기 (이름이 바뀐 파일도 추적)

git log --follow -p -- <file_path>

단일 브랜치 클론

git clone -b <branch-name> --single-branch https://github.com/user/repo.git

새로운 브랜치 생성과 동시에 스위칭

git checkout -b <branch-name>

다른 방법:

git branch <branch-name>&& git checkout <branch-name>

커밋시 파일 모드 변경 무시

git config core.fileMode false

Git 터미널 색상 출력 비활성화

git config --global color.ui false

특정 명령어에 대한 색상 설정 지정하기

git config --global <specific command e.g branch, diff><true, false or always>

모든 로컬 브랜치를 최근 커밋 날짜를 기준으로 정렬해 나열하기

git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/

트래킹된 파일에서 패턴(정규식이나 문자열)에 매칭되는 라인 검색

git grep --heading --line-number 'foo bar'

저장소의 얕은 카피 버전 클론하기

git clone https://github.com/user/repo.git --depth 1

모든 브랜치에서 주어진 텍스트로 커밋 로그 검색하기

git log --all --grep='<given-text>'

브랜치의 첫 커밋 가져오기 (마스터 브랜치로부터 시작된)

git log master..<branch-name> --oneline | tail -1

스테이징된 파일들 언스테이징하기

git reset HEAD <file-name>

원격 저장소에 강제 푸시하기

git push -f <remote-name><branch-name>

저장소명 추가하기

git remote add <remote-nickname><remote-url>

주어진 파일의 각 라인별 author, 시간 그리고 최종 리비전명 보기

git blame <file-name>

Author와 제목으로 커밋 그룹핑하기

git shortlog

다른 사람이 작업한 내용을 덮어쓰지 않고 강제 푸시하기

git push --force-with-lease <remote-name><branch-name>

특정 author가 기여한 라인수 보기

git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | gawk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s removed lines: %s total lines: %s", add, subs, loc }' -

다른 방법:

git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | awk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s, removed lines: %s, total lines: %s", add, subs, loc }' - # on Mac OSX

Revert: 머지 복구하기

git revert -m 1 <commit-ish>

특정 브랜치의 커밋 수 출력하기

git rev-list --count <branch-name>

별칭: git undo

git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'

오브젝트에 노트(메모) 추가하기

git notes add -m 'Note on the previous commit....'

모든 깃 노트 보기

git log --show-notes='*'

다른 저장소에 있는 커밋 적용하기

git --git-dir=<source-dir>/.git format-patch -k -1 --stdout <SHA1>| git am -3 -k

페치 레퍼런스 지정하기

git fetch origin master:refs/remotes/origin/mymaster

두 브랜치의 공통 조상 커밋 찾기

diff -u <(git rev-list --first-parent BranchA)<(git rev-list --first-parent BranchB)| sed -ne 's/^ //p'| head -1

푸시되지 않은 커밋들 나열하기

git log --branches --not --remotes

다른 방법:

git log @{u}..
git cherry -v

공백 변경사항을 제외한 모든 변경사항 추가하기

git diff --ignore-all-space | git apply --cached

깃 설정 [로컬/글로벌] 수정하기

git config [--global] --edit

특정 구간에서 blame 정보 보기

git blame -L <start>,<end>

Git의 논리적 변수 보기

git var -l |<variable>

패치 파일 미리 포맷팅하기

git format-patch -M upstream..topic

저장소명 가져오기

git rev-parse --show-toplevel

특정 날짜 구간 사이의 커밋 로그 출력하기

git log --since='FEB 1 2017' --until='FEB 14 2017'

로그에서 author 제외하기

git log --perl-regexp --author='^((?!excluded-author-regex).*)

브랜치의 수정사항 요약하기

git request-pull v1.0 https://git.ko.xz/project master:for-linus

원격 저장소의 모든 레퍼런스 나열하기

git ls-remote git://git.kernel.org/pub/scm/git/git.git

트래킹되지 않은 파일들 백업하기

git ls-files --others -i --exclude-standard | xargs zip untracked.zip

모든 git 명령어 별칭 나열하기

git config -l | grep alias| sed 's/^alias\.//g'

다른 방법:

git config -l | grep alias| cut -d '.' -f 2

git 상태 간략하게 보기

git status --short --branch

하루 전의 커밋으로 체크아웃하기

git checkout master@{yesterday}

About

📚 Git 팁 모음집 (https://github.com/git-tips/tips 한국어 버전)

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Git Tips

git tips의 한국어 버전 문서입니다.

English | 中文 | Русский | Tiếng Việt

팁 툴

목차

참고로 모든 명령어는 다음 버전에서 테스트 되었습니다: git version 2.7.4 (Apple Git-66).

20개 내외의 명령어로 Git 사용하기

git help everyday

Git과 함께 제공되는 유용한 가이드라인 보기

git help -g

내용으로 변경사항 검색

git log -S'<a term in the source>'

원격지 동기화 및 로컬 변경사항 덮어쓰기

git fetch origin && git reset --hard origin/master && git clean -f -d

특정 커밋까지의 모든 파일 나열하기

git ls-tree --name-only -r <commit-ish>

첫 번째 커밋 초기화

git update-ref -d HEAD

충돌된 모든 파일 나열하기

git diff --name-only --diff-filter=U

특정 커밋에서 변경된 모든 파일 나열하기

git diff-tree --no-commit-id --name-only -r <commit-ish>

마지막 커밋 이후로 스테이징되지 않은 변경사항 보기

git diff

커밋을 하기 위해 스테이징된 변경사항 보기

git diff --cached

다른 방법:

git diff --staged

스테이징된 변경사항과 스테이징되지 않은 변경사항 모두 보기

git diff HEAD

이미 마스터 브랜치에 머지된 모든 브랜치 나열하기

git branch --merged master

이전 브랜치로 전환하기

git checkout -

다른 방법:

git checkout @{-1}

이미 마스터 브랜치에 머지된 모든 브랜치들 삭제하기

git branch --merged master | grep -v '^\*'| xargs -n 1 git branch -d

다른 방법:

git branch --merged master | grep -v '^\*\| master'| xargs -n 1 git branch -d # will not delete master if master is not checked out

모든 브랜치들 및 그 브랜치들의 업스트림과 마지막 커밋 나열하기

git branch -vv

업스트림 브랜치 설정 (트래킹)

git branch -u origin/mybranch

로컬 브랜치 삭제

git branch -d <local_branchname>

원격 브랜치 삭제

git push origin --delete <remote_branchname>

다른 방법:

git push origin :<remote_branchname>

로컬 태그 삭제

git tag -d <tag-name>

원격 태그 삭제

git push origin :refs/tags/<tag-name>

로컬 변경사항을 헤드의 마지막 내용으로 되돌리기

git checkout -- <file_name>

Revert: 새로운 커밋을 생성하면서 커밋 되돌리기

git revert <commit-ish>

Reset: 커밋 제거 (프라이빗 브랜치에서만 사용하길 권고)

git reset <commit-ish>

이전 커밋 메시지 변경

git commit -v --amend

브랜치의 커밋중 업스트림에 머지되지 않은 커밋 히스토리 보기

git cherry -v master

Author 수정하기

git commit --amend --author='Author Name <email@address.com>'

글로벌 설정에서 변경된 author로 author 재설정하기

git commit --amend --reset-author --no-edit

원격지 URL 변경하기

git remote set-url origin <URL>

모든 원격지 레퍼런스 리스트 나열하기

git remote

다른 방법:

git remote show

모든 로컬 및 원격지 브랜치 나열하기

git branch -a

원격지 브랜치만 나열하기

git branch -r

파일 변경사항의 전체가 아닌 일부만 스테이징하기

git add -p

Git 배시 자동완성 사용하기

curl http://git.io/vfhol >~/.git-completion.bash &&echo'[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash'>>~/.bashrc

2주 전부터 현재까지의 변경사항 보기

git log --no-merges --raw --since='2 weeks ago'

다른 방법:

git whatchanged --since='2 weeks ago'

마스터로부터 포크한 이후에 생성된 모든 커밋 보기

git log --no-merges --stat --reverse master..

cherry-pick을 사용해 브랜치간 커밋 가져오기

git checkout <branch-name>&& git cherry-pick <commit-ish>

해당 커밋 해시를 가지고 있는 브랜치들 검색하기

git branch -a --contains <commit-ish>

다른 방법:

git branch --contains <commit-ish>

Git 명령어 별칭 지정

git config --global alias.<handle><command> git config --global alias.st status

커밋하지 않은 트래킹된 파일들의 상태 저장하기

git stash

다른 방법:

git stash save

스테이징되지 않은 변경사항들의 현재 상태를 트래킹된 파일로 저장하기

git stash -k

다른 방법:

git stash --keep-index
git stash save --keep-index

트래킹되지 않은 파일들까지 모두 포함해 현재 상태 저장하기

git stash -u

다른 방법:

git stash save -u
git stash save --include-untracked

현재 상태를 메시지와 함께 저장하기

git stash save <message>

모든 무시된 파일, 트래킹되지 않은 파일, 트래킹된 파일들의 현재 상태 저장하기

git stash -a

다른 방법:

git stash --all
git stash save --all

저장된 모든 스태시 리스트 나열하기

git stash list

스태시 리스트에서 삭제하지 않고 스태시 적용하기

git stash apply <stash@{n}>

마지막으로 저장된 스태시 상태를 적용하고 스태시 리스트에서 삭제하기

git stash pop

다른 방법:

git stash apply stash@{0} && git stash drop stash@{0}

저장된 모든 스태시 삭제하기

git stash clear

다른 방법:

git stash drop <stash@{n}>

스태시로부터 단일 파일 가져오기

git checkout <stash@{n}> -- <file_path>

다른 방법:

git checkout stash@{0} -- <file_path>

트래킹된 파일들 모두 보기

git ls-files -t

트래킹되지 않은 파일들 모두 보기

git ls-files --others

무시된 파일들 모두 보기

git ls-files --others -i --exclude-standard

저장소에 새로운 워킹 트리 생성하기 (git 2.5)

git worktree add -b <branch-name><path><start-point>

HEAD로부터 새로운 워킹 트리 생성하기

git worktree add --detach <path> HEAD

파일을 삭제하지 않고 언트래킹하기

git rm --cached <file_path>

다른 방법:

git rm --cached -r <directory_path>

트래킹되지 않은 파일/디렉토리를 실제로 삭제하기 전에 어떤 파일/디렉토리가 삭제되는지 테스트 해보기

git clean -n

트래킹되지 않은 파일들 강제로 삭제하기

git clean -f

트래킹되지 않은 디렉토리 강제로 삭제하기

git clean -f -d

다른 방법:

git clean -df

모든 서브 모듈 업데이트하기

git submodule foreach git pull

다른 방법:

git submodule update --init --recursive
git submodule update --remote

현재 브랜치에서 아직 마스터에 머지되지 않은 모든 커밋들 보기

git cherry -v master

다른 방법:

git cherry -v master <branch-to-be-merged>

브랜치명 수정하기

git branch -m <new-branch-name>

다른 방법:

git branch -m [<old-branch-name>] <new-branch-name>

'feature' 브랜치를 마스터에 리베이스한 후 마스터에 머지하기

git rebase master feature && git checkout master && git merge -

마스터 브랜치 아카이브

git archive master --format=zip --output=master.zip

커밋 메시지는 변경하지 않고 이전 커밋 변경하기

git add --all && git commit --amend --no-edit

원격지에서 삭제된 원격 브랜치 레퍼런스 제거하기

git fetch -p

다른 방법:

git remote prune origin

첫 리비전의 커밋 해시값 가져오기

 git rev-list --reverse HEAD | head -1

다른 방법:

git rev-list --max-parents=0 HEAD
git log --pretty=oneline | tail -1 | cut -c 1-40
git log --pretty=oneline --reverse | head -1 | cut -c 1-40

버전 트리 시각화

git log --pretty=oneline --graph --decorate --all

다른 방법:

gitk --all

트래킹된 하위폴더를 gh-pages 브랜치로 배포하기

git subtree push --prefix subfolder_name origin gh-pages

subtree를 사용해 저장소에 프로젝트 추가하기

git subtree add --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master

subtree를 사용해 관련된 프로젝트의 최신 변경사항을 저장소로 가져오기

git subtree pull --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master

브랜치를 히스토리와 함께 파일로 추출하기

git bundle create <file><branch-name>

번들 가져오기

git clone repo.bundle <repo-dir> -b <branch-name>

현재 브랜치명 가져오기

git rev-parse --abbrev-ref HEAD

커밋시 파일 무시하기 (예를 들어, Changelog 파일)

git update-index --assume-unchanged Changelog; git commit -a; git update-index --no-assume-unchanged Changelog

리베이스 전에 변경사항 스태시하기

git rebase --autostash

ID로 풀 리퀘스트를 로컬 저장소로 가져오기

git fetch origin pull/<id>/head:<branch-name>

다른 방법:

git pull origin pull/<id>/head:<branch-name>

현재 브랜치의 가장 최근 태그 보기

git describe --tags --abbrev=0

diff 워드 단위로 보기

git diff --word-diff

diff 도구를 사용해 변경사항 보기

git difftool -t <commit1><commit2><path>

트래킹된 파일의 변경사항 무시하기

git update-index --assume-unchanged <file_name>

assume-unchanged 되돌리기

git update-index --no-assume-unchanged <file_name>

.gitignore에 명시된 파일들 삭제하기

git clean -X -f

삭제된 파일 복구하기

git checkout <deleting_commit>^ -- <file_path>

특정 커밋으로의 파일로 복구하기

git checkout <commit-ish> -- <file_path>

pull시 머지하는 대신 항상 리베이스 하기

git config --global pull.rebase true

다른 방법:

#git < 1.7.9
git config --global branch.autosetuprebase always

모든 별칭과 설정값들 나열하기

git config --list

대소문자 구별 활성화

git config --global core.ignorecase false

커스텀 에디터 추가하기

git config --global core.editor '$EDITOR'

오타 자동 수정 활성화

git config --global help.autocorrect 1

변경사항이 어떤 릴리즈에 속하는지 확인하기

git name-rev --name-only <SHA-1>

명령어 테스트 해보기 (dry-run 플래그를 지원하는 모든 명령어에서 가능)

git clean -fd --dry-run

커밋이 이전 커밋의 수정 버전임을 표시하기

git commit --fixup <SHA-1>

fixup 커밋을 일반 커밋으로 스쿼시하기

git rebase -i --autosquash

커밋시 스테이징된 파일들 스킵하기

git commit --only <file_path>

대화형으로 스테이징하기

git add -i

무시된 파일들 나열하기

git check-ignore *

무시된 파일들 상태 출력

git status --ignored

Branch2에는 없고 Branch1에만 있는 커밋들 나열하기

git log Branch1 ^Branch2

마지막 n개의 커밋 나열하기

git log -<n>

다른 방법:

git log -n <n>

이전에 충돌을 해결했던 방법을 기록하고 재사용하기

git config --global rerere.enabled 1

모든 충돌된 파일들 에디터로 열기

git diff --name-only | uniq | xargs $EDITOR

unpacked 오브젝트의 갯수와 디스크 사용량 보기

git count-objects --human-readable

오브젝트 데이터베이스에서 도달할 수 없는 오브젝트들 제거하기

git gc --prune=now --aggressive

gitweb으로 워킹 디렉토리 탐색하기

git instaweb [--local] [--httpd=<httpd>] [--port=<port>] [--browser=<browser>]

커밋 로그에서 GPG 시그니쳐 보기

git log --show-signature

글로벌 설정에서 엔트리 제거하기

git config --global --unset <entry-name>

히스토리가 없는 새로운 브랜치로 체크아웃하기

git checkout --orphan <branch_name>

다른 브랜치에서 파일내용 가져오기

git show <branch_name>:<file_name>

루트 커밋과 머지 커밋만 나열하기

git log --first-parent

대화형 리베이스로 이전 두 커밋 수정하기

git rebase --interactive HEAD~2

작업중인 브랜치들 모두 나열하기

git checkout master && git branch --no-merged

이진 탐색으로 좋은/안좋은 커밋 검색하기

git bisect start # Search start 
git bisect bad # Set point to bad commit 
git bisect good v2.6.13-rc2 # Set point to good commit|tag 
git bisect bad # Say current state is bad 
git bisect good # Say current state is good 
git bisect reset # Finish search 

pre-commit과 commit-msg 깃 후킹 우회하기

git commit --no-verify

특정 파일에 대한 커밋과 변경사항 나열하기 (이름이 바뀐 파일도 추적)

git log --follow -p -- <file_path>

단일 브랜치 클론

git clone -b <branch-name> --single-branch https://github.com/user/repo.git

새로운 브랜치 생성과 동시에 스위칭

git checkout -b <branch-name>

다른 방법:

git branch <branch-name>&& git checkout <branch-name>

커밋시 파일 모드 변경 무시

git config core.fileMode false

Git 터미널 색상 출력 비활성화

git config --global color.ui false

특정 명령어에 대한 색상 설정 지정하기

git config --global <specific command e.g branch, diff><true, false or always>

모든 로컬 브랜치를 최근 커밋 날짜를 기준으로 정렬해 나열하기

git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/

트래킹된 파일에서 패턴(정규식이나 문자열)에 매칭되는 라인 검색

git grep --heading --line-number 'foo bar'

저장소의 얕은 카피 버전 클론하기

git clone https://github.com/user/repo.git --depth 1

모든 브랜치에서 주어진 텍스트로 커밋 로그 검색하기

git log --all --grep='<given-text>'

브랜치의 첫 커밋 가져오기 (마스터 브랜치로부터 시작된)

git log master..<branch-name> --oneline | tail -1

스테이징된 파일들 언스테이징하기

git reset HEAD <file-name>

원격 저장소에 강제 푸시하기

git push -f <remote-name><branch-name>

저장소명 추가하기

git remote add <remote-nickname><remote-url>

주어진 파일의 각 라인별 author, 시간 그리고 최종 리비전명 보기

git blame <file-name>

Author와 제목으로 커밋 그룹핑하기

git shortlog

다른 사람이 작업한 내용을 덮어쓰지 않고 강제 푸시하기

git push --force-with-lease <remote-name><branch-name>

특정 author가 기여한 라인수 보기

git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | gawk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s removed lines: %s total lines: %s", add, subs, loc }' -

다른 방법:

git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | awk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s, removed lines: %s, total lines: %s", add, subs, loc }' - # on Mac OSX

Revert: 머지 복구하기

git revert -m 1 <commit-ish>

특정 브랜치의 커밋 수 출력하기

git rev-list --count <branch-name>

별칭: git undo

git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'

오브젝트에 노트(메모) 추가하기

git notes add -m 'Note on the previous commit....'

모든 깃 노트 보기

git log --show-notes='*'

다른 저장소에 있는 커밋 적용하기

git --git-dir=<source-dir>/.git format-patch -k -1 --stdout <SHA1>| git am -3 -k

페치 레퍼런스 지정하기

git fetch origin master:refs/remotes/origin/mymaster

두 브랜치의 공통 조상 커밋 찾기

diff -u <(git rev-list --first-parent BranchA)<(git rev-list --first-parent BranchB)| sed -ne 's/^ //p'| head -1

푸시되지 않은 커밋들 나열하기

git log --branches --not --remotes

다른 방법:

git log @{u}..
git cherry -v

공백 변경사항을 제외한 모든 변경사항 추가하기

git diff --ignore-all-space | git apply --cached

깃 설정 [로컬/글로벌] 수정하기

git config [--global] --edit

특정 구간에서 blame 정보 보기

git blame -L <start>,<end>

Git의 논리적 변수 보기

git var -l |<variable>

패치 파일 미리 포맷팅하기

git format-patch -M upstream..topic

저장소명 가져오기

git rev-parse --show-toplevel

특정 날짜 구간 사이의 커밋 로그 출력하기

git log --since='FEB 1 2017' --until='FEB 14 2017'

로그에서 author 제외하기

git log --perl-regexp --author='^((?!excluded-author-regex).*)

브랜치의 수정사항 요약하기

git request-pull v1.0 https://git.ko.xz/project master:for-linus

원격 저장소의 모든 레퍼런스 나열하기

git ls-remote git://git.kernel.org/pub/scm/git/git.git

트래킹되지 않은 파일들 백업하기

git ls-files --others -i --exclude-standard | xargs zip untracked.zip

모든 git 명령어 별칭 나열하기

git config -l | grep alias| sed 's/^alias\.//g'

다른 방법:

git config -l | grep alias| cut -d '.' -f 2

git 상태 간략하게 보기

git status --short --branch

하루 전의 커밋으로 체크아웃하기

git checkout master@{yesterday}

About

📚 Git 팁 모음집 (https://github.com/git-tips/tips 한국어 버전)

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors