Je l'ai fait pour un exemple de projet sur Github qui est appelé hesco/hesco-weave comme suit:
je boucle, jq, coupé et commandes queue dans les exemples suivants, vous devez donc les avoir avant d'exécuter les exemples.
Première, les deux balises dernières du projet se trouvent:
[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
Ou si vous avez une version checkouted du projet:
[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
le sha de refs sont les suivantes :
[email protected]: ~ $ git ls-remote | tail -n 2
be74d8368acd4815b6863daded46a232944e0d84 refs/tags/v0.8.6
9181306caa304b4cf8b3764b1446c0c4006833d8 refs/tags/v0.8.7
Deuxième, un dépôt git est créé:
[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
Troisième, la balise v0.8.6 du référentiel du Github est ajouté au référentiel créé comme sous-arbre:
[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'
info Trace:
[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
Enfin,, la sous-arborescence weave avec l'étiquette plus récente v0.8.7 est fusionné avec 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(-)
info Trace:
[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
Si je ne sais pas fournir Bproject/maître, comment git que je suis la fusion à distance avec? – cmaughan
@cmaughan Git ne sait pas. Tout ce qu'il sait sont sha et chaque sha (représenté aussi par tag, ou Bproject/master) se réfère à un commit, qui a des parents, et ainsi de suite. C'est pourquoi vous récupérez (option '-f' dans' git remote') les changements depuis le dépôt distant - vous obtenez tous les commits et leurs shas. Et puis vous fusionnez un arbre (distant, par sha bien sûr) à votre arbre. J'espère que c'est comme ça que ça fonctionne – MBO
Okay - ça me semble bien! La question des tags de collision est quelque chose que je me suis demandé - si j'ai un tag - v1.5 sur mon application, et la télécommande comme une balise v1.5, comment git régler cela? De toute façon, semble être la solution que je cherchais ... – cmaughan