Skip to content
jaeseok.an edited this page Sep 18, 2020 · 14 revisions

SSH key설정

  • github설정
    • /settings/SSK-KEY에 SSH id_rsa.pub 내용을 추가 (여러개 추가 가능)
  • Host 설정
    • github.com으로 접속시 ssh config에 특정 key
          HostName       github.com
          IdentityFile   ~/.ssh/everjs_id_rsa
          IdentitiesOnly yes```
      
      
  • git config 설정
    • SSH를 사용하게 해야 인증 가능
      • git config --global url.ssh://git@github.com/.insteadOf https://github.com/

branch 삭제

git checkout topic/newsyncer

git checkout master

git branch -D topic/newsyncer

git push origin :topic/newsyncer

git에서 submodue  commit ID 확인

git log --patch-with-stat aergo-protobuf

git에서 현재 branch를 임시로 복사해놓고 remote를 받아오고 싶을때

  • 현재 branch에서 새로운 branch를 딴다.
  • remote에서 branch를 checkout한다. 
  • remote branch에 old branch내용을 cherry-pick한다. 

remote branch가 꼬였을때

git gc --prune=now

git remote prune origin

git submodule

  • 사용법
    • 추가 - git submodule add git://github.com/chneukirchen/rack.git rack
    • clone시 - git submodule init ; git submodule update;
  • submodule 수정하기
    • 방법1
      • submodule directory에서 수정사항 merge
      • superproject에서 commit
    • 방법2
      • remote에서 최신 수정사항 받기
      • '''git submodule update --remote'''
    • 수정사항 보기
      • git config status.submodulesummary 1
  • 서브모듈 사용할 때 주의할 점들
    서브모듈은 어렵지 않게 사용할 수 있지만, 서브모듈의 코드를 수정하는 경우에는 주의가 필요하다. git submodule update 명령을 실행시키면 특정 브랜치가 아니라 슈퍼프로젝트에 저장된 커밋을 Checkout해 버린다. 그러면 detached HEAD라고 부르는 상태가 된다. detached HEAD는 HEAD가 브랜치나 태그 같은 간접 레퍼런스를 가리키지 않고 커밋을 가리키는 것을 말한다. 데이터를 잃어 버릴 수도 있기 때문에 일반적으로 detached HEAD 상태는 피해야 한다.

== Branch merge ==

  • mybranch merge 하기
    • local의 mybranch를 merge하므로 최신으로 update필요
      git co mybranch
      git pull git merge mybranch
    • remote를 바로 merge git merge origin/mybranch

== Merge commit revert하기 ==

  • merge commit을 revert하면 해당 branch를 다시 merge하기 힘들다.
    • revert한후 branch를 수정후 다시 merge해야 하는 경우, 그냥 merge를 다시 하면 해당 branch를 마지막까지 merge할수 있다.
  • merge commit을 revert한 후 확인
    git diff merge전commit HEAD
  • revert했던 브랜치를 다시 merge하면 처음에 merge하고 revert한 내용은 다시 merge하지 않는다. 따라서 merge commit은 revert하지 않는게 좋다
    • 기존 revert commit을 revert하고 merge를 재시도하면 된다. git revert revertmerge
      git merge branch

test

Clone this wiki locally