2010-01-23 4 views
6

서브 트리를 사용하여 원격 프로젝트를 내 자신의 자식 트리에서 디렉토리로 가져 오려고합니다. 여기 지침을 따랐습니다. using subtree merge힘내 서브 트리 태그

하지만 태그를 체크 아웃하는 방법을 모르겠습니다. 이것은 일반적인 요청이라고 생각합니다. 외부 프로젝트를 가져오고 소스의 안전한 태그 버전을 얻고 싶습니다. 하위 트리 병합 솔루션은 훌륭하게 작동하지만 원하는 태그를 얻는 방법을 모르겠습니다. 자식을 사랑하지만 때로는 내 머리가 아파요 ....

답변

3

git tag을 입력하면 리포지토리의 모든 태그 목록이 표시됩니다. 원격 태그도 여기에 표시되며 충돌하는지 (확인하지 않았 음), 그리고 어떤 태그가 리포지토리로 가져 왔는지 확인하는 방법을 알지 못합니다.

하지만 내가 선택한 것은 리모컨을 추가하고 다른 프로젝트에서 가져 오면 가져올 태그를 확인하는 것입니다. 그런 다음 해당 태그와 병합 할 수 있습니다 (예 :

git merge -s ours --no-commit v0.1.2 # instead of: Bproject/master (2) 
git read-tree --prefix=dir-B/ -u v0.1.2 # instead of: Bproject/master (3) 

).

는 조금 도움이되기를 바랍니다,하지만 난

+0

, 어떻게 자식 원격 I가 합병있어 알고 않습니다를? – cmaughan

+0

@cmaughan 힘내는 모른다. 모든 것이 sha이고 각 sha (태그 또는 Bproject/master로도 표현됨)는 부모가있는 커밋을 참조하는 식으로 진행됩니다. 그래서 원격 저장소에서''git remote'에서'-f' 옵션을 가져 와서 모든 커밋과 섀시를 가져옵니다. 그리고 나서 당신은 당신의 나무에 어떤 나무 (원격, 물론 sha)를 합칩니다. 그것이 어떻게 작동하는지 희망 – MBO

+0

좋아 - 나에게 좋은 소리! 충돌 태그 문제는 제가 궁금해했던 것입니다. - 내 앱에 v1.5 태그가 있고 v1.5 태그로 리모컨이 있으면 어떻게 처리합니까? 어느 쪽이든, 내가 찾고 있던 해결책 인 것 같다. – cmaughan

0

을 다음과 같이 hesco/hesco-weave라고 Github에서에 샘플 프로젝트 : 나는 컬을 사용

, jq는, 절단 및 예제를 실행하기 전에이 필요하므로 꼬리, 다음 예제에서 명령. 다음과 같이

[email protected]: ~/github/hesco-weave (master) $ git remote -v 
origin https://github.com/hesco/hesco-weave.git (fetch) 
origin https://github.com/hesco/hesco-weave.git (push) 
[email protected]: ~/github/hesco-weave (master) $ git tag -l 
v0.1 
v0.2 
v0.3 
v0.4 
v0.5 
v0.6 
v0.7 
v0.8 
v0.8.6 
v0.8.7 

[email protected]: ~/github/hesco-weave (master) $ git tag -l | tail -n 2 
v0.8.6 
v0.8.7 

심판의 샤입니다

[email protected]: ~ $ curl -s https://api.github.com/repos/hesco/hesco-weave/git/refs/tags | jq -r ".[].ref" | cut -d "/" -f 3 
v0.1 
v0.2 
v0.3 
v0.4 
v0.5 
v0.6 
v0.7 
v0.8 
v0.8.6 
v0.8.7 

[email protected]: ~ $ curl -s https://api.github.com/repos/hesco/hesco-weave/git/refs/tags | jq -r ".[].ref" | cut -d "/" -f 3 | tail -n 3 
v0.8.6 
v0.8.7 

를 또는 프로젝트의 checkouted 버전이있는 경우 : 먼저

, 프로젝트의 마지막 두 태그 발견 :

[email protected]: ~ $ git ls-remote | tail -n 2 
be74d8368acd4815b6863daded46a232944e0d84 refs/tags/v0.8.6 
9181306caa304b4cf8b3764b1446c0c4006833d8 refs/tags/v0.8.7 

둘째, 자식 저장소가 생성됩니다 :

[email protected]: ~/test (master) $ git subtree add --squash --prefix=weave https://github.com/hesco/hesco-weave.git v0.8.6 

git fetch https://github.com/hesco/hesco-weave.git v0.8.6 
warning: no common commits 
remote: Counting objects: 543, done. 
remote: Compressing objects: 100% (193/193), done. 
remote: Total 543 (delta 306), reused 536 (delta 306), pack-reused 0 
Receiving objects: 100% (543/543), 93.19 KiB | 0 bytes/s, done. 
Resolving deltas: 100% (306/306), done. 
From https://github.com/hesco/hesco-weave 
* tag    v0.8.6  -> FETCH_HEAD 
Added dir 'weave' 

추적 정보 :

[email protected]: ~ $ mkdir -p ~/test 
[email protected]: ~ $ cd ~/test 
[email protected]: ~/test $ git init 
Initialized empty Git repository in ~/test/.git/ 
[email protected]: ~/test $ touch README.md 
[email protected]: ~/test $ git add . 
[email protected]: ~/test $ git commit -m "README.md added" 
[master (root-commit) b1ac90e] README.md added 
1 file changed, 0 insertions(+), 0 deletions(-) 
create mode 100644 README.md 
[email protected]: ~/test (master) $ git log 
commit 19c0570a414c4fd1635444b7a937dfc41c93a847 
Author: Me <[email protected]> 
Date: Wed Jun 14 13:02:05 2017 +0200 

README.md added 

셋째는 Github에서의 저장소의 v0.8.6 태그는 하위 트리로 생성 된 저장소에 추가됩니다

[email protected]: ~/test (master) $ git log 
commit e5dc318c4437cd22ebddb9e82e8c419aef72a781 
Merge: b1ac90e 19c0570 
Author: me <[email protected]> 
Date: Wed Jun 14 13:02:25 2017 +0200 

    Merge commit '19c0570a414c4fd1635444b7a937dfc41c93a847' as 'weave' 

commit 19c0570a414c4fd1635444b7a937dfc41c93a847 
Author: me <[email protected]> 
Date: Wed Jun 14 13:02:25 2017 +0200 

    Squashed 'weave/' content from commit be74d83 

    git-subtree-dir: weave 
    git-subtree-split: be74d8368acd4815b6863daded46a232944e0d84 

commit b1ac90efbfe5978bac52984c29e6ec7904ed9a75 
Author: me <[email protected]> 
Date: Wed Jun 14 13:02:05 2017 +0200 

    README.md added 

마지막으로, 최신 태그 v0.8이 포함 된 위브 하위 트리.7 git subtree pull로 병합 :

[email protected]: ~/test (master) $ git subtree pull --squash --prefix=weave https://github.com/hesco/hesco-weave.git v0.8.7 

warning: no common commits 
remote: Counting objects: 548, done. 
remote: Compressing objects: 100% (195/195), done. 
remote: Total 548 (delta 311), reused 541 (delta 309), pack-reused 0 
Receiving objects: 100% (548/548), 90.50 KiB | 0 bytes/s, done. 
Resolving deltas: 100% (311/311), done. 
From https://github.com/hesco/hesco-weave 
* tag    v0.8.7  -> FETCH_HEAD 
Merge made by the 'recursive' strategy. 
weave/Changelog  | 1 + 
weave/Modulefile | 2 +- 
weave/README.md  | 2 +- 
weave/metadata.json | 2 +- 
4 files changed, 4 insertions(+), 3 deletions(-) 

추적 정보 : 나는 Bproject/마스터를 제공하지 않으면

[email protected]: ~/test (master) $ git log 
commit 9116e133c8d84de1df9883a8b5558a2350ebc86e 
Merge: e5dc318 eb2e273 
Author: me <[email protected]> 
Date: Wed Jun 14 13:03:16 2017 +0200 

    Merge commit 'eb2e2733a75d59eb1adebf4755d5b11cb74e2b98' 

commit eb2e2733a75d59eb1adebf4755d5b11cb74e2b98 
Author: me <[email protected]> 
Date: Wed Jun 14 13:03:16 2017 +0200 

    Squashed 'weave/' changes from be74d83..9181306 

    9181306 make release used to update version to v0.8.7 
    3871cf5 Update changelog, tag v0.8.6, fix link in README 
    REVERT: be74d83 Update changelog, tag v0.8.6, fix link in README 

    git-subtree-dir: weave 
    git-subtree-split: 9181306caa304b4cf8b3764b1446c0c4006833d8 

commit e5dc318c4437cd22ebddb9e82e8c419aef72a781 
Merge: b1ac90e 19c0570 
Author: me <[email protected]> 
Date: Wed Jun 14 13:02:25 2017 +0200 

    Merge commit '19c0570a414c4fd1635444b7a937dfc41c93a847' as 'weave' 

commit 19c0570a414c4fd1635444b7a937dfc41c93a847 
Author: me <[email protected]> 
Date: Wed Jun 14 13:02:25 2017 +0200 

    Squashed 'weave/' content from commit be74d83 

    git-subtree-dir: weave 
    git-subtree-split: be74d8368acd4815b6863daded46a232944e0d84 

commit b1ac90efbfe5978bac52984c29e6ec7904ed9a75 
Author: me <[email protected]> 
Date: Wed Jun 14 13:02:05 2017 +0200 

    README.md added 


[email protected]: ~/test (master) $ ll 
total 4 
-rw-rw-r-- 1 me me 0 Jun 14 13:01 README.md 
drwxrwxr-x 8 me me 4096 Jun 14 13:03 weave