Mon problème
Je tente de comprendre le fonctionnement des sous-modules Git. J'ai testé le scénario suivant:
- création d'un projet conteneur main utilisant le sous-module plugin1
- push main sur le remote
- clone main dans un repository local team1
- modifie team1 et plugin1
- push le tout vers remote
Ensuite:
- Mise à jour de main pour récupérer les modifs faites dans team1
- clone du remote dans team2
Il se passe quoi?
team2 a cloné toutes les modifs, tout va bien, les modifs sont donc bien dans le remote.
main ne récupère aucune des modifications.
Si je fais un fetch depuis main j'ai un message d'erreur que je ne comprends pas:
$ git fetch
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 320 bytes | 21.00 KiB/s, done.
From ..\Remotes\main
e45fe74..c1a1094 master -> origin/master
Fetching submodule plugin1
fatal: git upload-pack: not our ref e43b6a164b70e69bf31456bf4faabbf7b3f12f26
fatal: remote error: upload-pack: not our ref e43b6a164b70e69bf31456bf4faabbf7b3f12f26
Errors during submodule fetch:
plugin1
J'ai testé ce scénario sans le volet sous-module et tout fonctionne.
Ma question
Pourquoi main n'est pas mis à jour correctement? Que puis-je faire?
Comment j'ai procédé
J'ai écris ce script batch qui effectue le test complet:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90 mkdir demo cd demo @echo remotes @echo -------------------------- mkdir remotes cd remotes @echo Initialize remotes @echo -------------------------- mkdir main cd main git init --bare cd .. mkdir plugin1 cd plugin1 git init --bare cd ../.. @echo Create submodule repository @echo -------------------------- mkdir plugin1 cd plugin1 git init echo foofoo > lib1.txt git add lib1.txt git commit -m "first commit plugin1" git remote add origin1 ..\Remotes\plugin1 git push --set-upstream origin1 master cd .. @echo Create main repository @echo -------------------------- mkdir main cd main git init echo barbarbar > code.txt git add code.txt git commit -m "first commit main" git submodule add ../plugin1 plugin1 git commit -m "Ajout du sous-module plugin1" git remote add origin ..\Remotes\main git push --set-upstream origin master cd .. @echo Team1 get project and modify it @echo -------------------------- git clone --recursive remotes/main team1 cd team1 cd plugin1 git checkout master @echo modify plugin1 echo "modify plugin1" > file1.txt git add file1.txt git commit -m "Commit test 1" git push cd .. @echo modify main echo "modif main 1" >> code.txt git add * git commit -m "2nd commit main" git push cd .. @echo go back to main @echo -------------------------- cd main exit /b git submodule update --init --recursive cd .. @echo Team2 get new project @echo -------------------------- git clone --recursive remotes/main team2
Partager