git 명령 비망록

5563 단어 Git

개시하다


제목과 같이 "그게 뭐였지?"시간의 자기 노트.
기재 명령은 가능한 한 -help시의 기재와 동일하게 기재한다.
언제든지 업데이트할 수 있습니다.

분기 작업


원격 분기 생성/업데이트


체크아웃 중인 로컬 지점을 직접push로 진행할 때

git push <repository> <refspec>

원격 지점을 지정해서push를 진행할 때

git push <repository> <localbranch>:<remotebranch>

로컬 브랜치 생성


지점을 창설하는 동시에 체크아웃

git checkout -b <branch> [<repository>/]<branch>git checkout -B에서 실행하면 같은 이름의 분기가 이미 있으면 덮어쓰기

upstream을 설정하면서 지점을 만듭니다

git branch -t <branchname> [<repository>/]<target_branchname>

빈 브랜치 생성하기

git checkout --orphan <newbranch>

브랜치 삭제


로컬 브랜치 삭제

git branch -d <branchname>

로컬 브랜치 강제 삭제

git branch -D <branchname>

원격 라이센스에서 분기 제거

git push --delete <repository> <refspec>

분기에서 upstream 설정하기

git branch -u <target_branchname>

분기 이름 바꾸기


일반적

git branch -m <oldbranch> <newbranch> 커밋되지 않은 변경 사항이 있으면 이름을 바꿀 수 없습니다.

강제 이름 바꾸기

git branch -M <oldbranch> <newbranch>

원격 작업


현재 원격 프로젝트 상태 표시

git remote show <repository>

원격 라이센스에 대한 정보 업데이트


실행 테스트

git remote prune --dry-run <repository>

반영

git remote prune <repository>

원격 분기 정보 업데이트


일반적

git fetch <repository>

업데이트에 분기 삭제 정보 포함

git fetch --prune <repository>

tag


창설


주석을 달다

git tag -a <tag_name> (<target_branch>)

원격 라이센스에 반영

git push <repository> (<tagname>|refs/tags/<tagname>)

대화의 무대

git add -i

commit


관문의 변경 사항을 제출합니다

git commit

모든 변경 내용 커밋

git commit -a

stash


보존

git stash save <message> 명령줄에서 입력했기 때문에 일본어가 바뀝니다.

목록 보기

git stash list

반영


current branch에 반영된 stash 삭제

git stash pop stash@{0}

current branch에 반영된 stash 저장

git stash apply stash@{0}

삭제


지정한 stash 삭제

git stash drop stash@{0}

모든 stash 삭제

git stash clear

관리된 버전의 파일 변경 사항 무시(update-idex)


assume-unchanged


설정

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

취소

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

설정 상태 확인

git ls-files -v | grep ^hassume-unchange가 설정한 파일 상태를 소문자로 표시

skip-worktree


설정

git update-index --skip-worktree <target_file>

취소

git update-index --no-skip-worktree <target_file>

설정 상태 확인

git ls-files -v | grep ^S skip-worktree에서 설정한 파일 상태가 S로 표시됩니다.

※ assume-unchanged와 skip-worktree의 차이 ※


assume-unchanged


그 파일이 작업 트리에서 변경되었어도git는 그 변경을 무시하고 변경되지 않았다.
  • Merge에서 결합된 소스의 컨텐트로 덮어씁니다.
  • reset --hard시에도 덮어씁니다.
  • skip-worktree


    만약 그 파일이 작업 트리에서 변경되었다면git는 그 변경을 유지할 것입니다.
  • Merge 시 로컬 상태가 우선적으로 유지됩니다.
  • reset --hard에도 컨디션은 유지된다.
  • 기타 명령


    커밋되었지만 캐시에서 제거되어 처음부터 존재하지 않음

    git rm --cached ./

    특정 모듈이 없는 경우


    서류

    git filter-branch --tree-filter 'rm -f <file>' HEAD

    카탈로그

    git filter-branch --tree-filter 'rm -rf <dir>' HEAD

    graph

    git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all

    conflict가 발생하면 명령줄에서 빠르게 병합


    병합보다는 충돌이 발생한 모듈이 제출한 처리 방법에 완전히 가깝다

    통합 소스 채택

    git checkout --theirs .

    결합된 소스 - 파일 단위 -

    git checkout --theirs <file>

    병합 대상 사용하기 (work 디렉터리)

    git checkout --ours .

    병합 대상(work 디렉토리) - 파일 단위 -

    git checkout --ours <file>

    좋은 웹페이지 즐겨찾기