Skip to content

Instantly share code, notes, and snippets.

@simnalamburt
Created October 24, 2016 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simnalamburt/0659caec16deb8840e8bba8d89a01350 to your computer and use it in GitHub Desktop.
Save simnalamburt/0659caec16deb8840e8bba8d89a01350 to your computer and use it in GitHub Desktop.

Git subtree merges

깃헙 문서가 git 2.9 변경사항을 반영하지 않아서 여기에 새로 씀

  1. 머지할 리포지터리를 먼저 git remote로 추가시킨다.

    git remote add blabla git@github.com:project/url.git
    git fetch blabla
  2. 리모트 blabla의 master 브랜치를 머지한다고 치면, 아래와 같이 하면 된다.

    git merge -s ours --no-commit --allow-unrelated-histories blabla/master
  3. read-tree 명령어로 해당 브랜치의 내용물을 디렉토리 한곳에 복사해온다. 머지해올 디렉토리 이름이 subproject/라고 한다면, 아래와 같이 하면 된다.

    git read-tree --prefix=subproject/ -u blabla/master
  4. 위의 명령어를 실행하면 커밋하기 직전 상태에서 멈추게되는데, 커밋하면 합체가 완료된다.

    git commit
References
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment