- 1. Command
특정 branch에서 특정 파일 혹은 폴더만 Update하고 싶을 때
$ git checkout --patch {bracnh} {file or folder}
$ git branch -d {branch_name} # merge 후 쓸모없는 브랜치만 삭제됨
$ git branch -D {branch_name} # 강제로 삭제 가능
checkout 안하고 해도 됨.
$ git push --delete {remote} {branch}
원격 브랜치를 로컬로 checkout한 후 원격브랜치에서 체크아웃한 로컬브랜치를 아래 명령어로 삭제하면 된다.
$ git co {branch_name} origin/{branch_name}
$ git push origin --delete {branch_name}
git remote prune origin
원하는 디렉토리에서 git init 후
$ git remote add origin {remote_name}
$ git fetch # 리모트 저장소의 파일, 브랜치 등을 가져온다.
tag 추가 후 git push {remote} {tag}
혹은
tag전부 push됨.
git push --tag
$ git tag -a v1.4 -m 'my version 1.4'
$ git tag v1.4-lw
- VSCode같은 에디터 이용하거나
- 명령줄에서 "를 시작하고 닫지 않고 엔터입력
$ git commit -m "
> Commit
> OK
> "
$ git checkout --orphan gh-pages
-i
대소문자 구분 안 함.
git log --oneline --grep Text -i
git log --author=tshyeon --grep=state
참고
git reset --hard
로 지운거 아니면 reflog
로 볼 수 있다.(복구가능)
- 파일 라인별 변경사항 보고 싶을 때 -p
$ git log -p {filename}
- 특정키워드 변경 확인
$ git log -p {filename} | grep '2011070102\|commit \|Author:\|Date:'
- 특정 리비전 확인
$ git show revision_number
- 특정 인물 로그
$ git log --author=username
- 단어기준 diff
$ git log -p --word-diff {filename}
- 브랜치 사이에 특정파일(폴더)만 diff
$ git diff {branch1} {branch2} -- {filename or directory}
자동으로 텍스트 편집기 실행됨.
$ git commit --amend
$ git reset --hard {리비전번호} // history를 없앤다.
$ git reset --soft {리비전번호} // history를 남긴다.
$ git blame {filename}
$ git blame -L 10,20 {filename} // 10번 줄에서 20번 줄까지 탐색
$ git blame -C {filename} // 리팩토링된 파일 추적 가능
git remote show origin`