Wiki » History » Version 12
Gateau, Thibault, 02/22/2019 03:37 PM
1 | 1 | Gateau, Thibault | h1. |
---|---|---|---|
2 | 1 | Gateau, Thibault | Create local git repository and initialize it |
3 | 1 | Gateau, Thibault | |
4 | 2 | Gateau, Thibault | h2. |
5 | 1 | Gateau, Thibault | #create a local git server |
6 | 9 | Gateau, Thibault | USER=charles |
7 | 2 | Gateau, Thibault | |
8 | 2 | Gateau, Thibault | #T1> |
9 | 1 | Gateau, Thibault | cd && mkdir serverTestGit && cd serverTestGit |
10 | 1 | Gateau, Thibault | mkdir projet.git && cd projet.git |
11 | 1 | Gateau, Thibault | git --bare init |
12 | 1 | Gateau, Thibault | |
13 | 2 | Gateau, Thibault | h2. |
14 | 1 | Gateau, Thibault | #initialize it |
15 | 2 | Gateau, Thibault | |
16 | 2 | Gateau, Thibault | #T2> |
17 | 1 | Gateau, Thibault | #cloner le repo pseudo-distant |
18 | 1 | Gateau, Thibault | cd && mkdir git && cd git |
19 | 12 | Gateau, Thibault | git clone ${USER}@localhost:~/serverTestGit/projet.git |
20 | 12 | Gateau, Thibault | |
21 | 7 | Gateau, Thibault | cd projet |
22 | 1 | Gateau, Thibault | |
23 | 1 | Gateau, Thibault | #configurer l'<user> local |
24 | 1 | Gateau, Thibault | git config --global user.email ${USER}@userplace.eu |
25 | 12 | Gateau, Thibault | |
26 | 9 | Gateau, Thibault | git config --global user.name ${USER} |
27 | 1 | Gateau, Thibault | |
28 | 1 | Gateau, Thibault | #faire un premier commit et le pusher |
29 | 9 | Gateau, Thibault | echo -e "lorem ispum \n titi \n toto" >> readme.md |
30 | 1 | Gateau, Thibault | git add readme.md |
31 | 1 | Gateau, Thibault | git commit -m "initial commit" |
32 | 1 | Gateau, Thibault | git push origin master |
33 | 1 | Gateau, Thibault | |
34 | 1 | Gateau, Thibault | h2. |
35 | 1 | Gateau, Thibault | #use it... |
36 | 10 | Gateau, Thibault | |
37 | 9 | Gateau, Thibault | echo -e "another toto" >> readme.md |
38 | 9 | Gateau, Thibault | git add readme.md |
39 | 9 | Gateau, Thibault | git commit -m "my second commit" |
40 | 9 | Gateau, Thibault | git push origin master |
41 | 9 | Gateau, Thibault | echo -e "another titi" >> readme.md |
42 | 9 | Gateau, Thibault | git add readme.md |
43 | 9 | Gateau, Thibault | git commit -m "my third commit" |
44 | 9 | Gateau, Thibault | git push origin master |
45 | 1 | Gateau, Thibault | |
46 | 1 | Gateau, Thibault | |
47 | 9 | Gateau, Thibault | h2. |
48 | 9 | Gateau, Thibault | #uses aliases |
49 | 10 | Gateau, Thibault | |
50 | 9 | Gateau, Thibault | git lg1 |
51 | 9 | Gateau, Thibault | wget https://sourceforge.isae.fr/projects/iut_testing/repository/revisions/master/entry/.gitconfig |
52 | 9 | Gateau, Thibault | cp |
53 | 9 | Gateau, Thibault | git config --global user.name ${USER} |
54 | 9 | Gateau, Thibault | git config --global user.email ${USER}@userplace.eu |
55 | 1 | Gateau, Thibault | |
56 | 9 | Gateau, Thibault | h2. |
57 | 9 | Gateau, Thibault | #conflict management |
58 | 10 | Gateau, Thibault | |
59 | 9 | Gateau, Thibault | #T3> dans un autre terminal |
60 | 9 | Gateau, Thibault | #cloner le repo pseudo-distant |
61 | 9 | Gateau, Thibault | USER=bob |
62 | 9 | Gateau, Thibault | cd && mkdir gitBob && cd gitBob |
63 | 9 | Gateau, Thibault | git clone ${USER}@localhost:~/serverTestGit/projet.git |
64 | 9 | Gateau, Thibault | cd projet |
65 | 9 | Gateau, Thibault | git clone ${USER}@localhost:~/serverTestGit |
66 | 9 | Gateau, Thibault | cd serverTestGit |
67 | 9 | Gateau, Thibault | git config --local user.name ${USER} |
68 | 9 | Gateau, Thibault | echo -e "lorem ispum \n titi \n Bob \n toto" > readme.md |
69 | 9 | Gateau, Thibault | git add readme.md |
70 | 9 | Gateau, Thibault | git commit -m "I want to add my name in the file!" |
71 | 9 | Gateau, Thibault | #Et la on ne push pas... |
72 | 9 | Gateau, Thibault | git lg1 |
73 | 9 | Gateau, Thibault | #* 199d358 - (3 seconds ago) I want to add my name in the file! - bob (HEAD, master) |
74 | 9 | Gateau, Thibault | #* 98c844b - (16 minutes ago) my third commit - charles (origin/master, origin/HEAD) |
75 | 9 | Gateau, Thibault | #* 327be69 - (16 minutes ago) my second commit - charles |
76 | 9 | Gateau, Thibault | #* 7562195 - (18 minutes ago) initial commit - charles |
77 | 9 | Gateau, Thibault | |
78 | 9 | Gateau, Thibault | |
79 | 9 | Gateau, Thibault | #T2> dans le terminal précédent: |
80 | 10 | Gateau, Thibault | |
81 | 9 | Gateau, Thibault | cd && cd git |
82 | 9 | Gateau, Thibault | cd projet |
83 | 9 | Gateau, Thibault | USER=charles |
84 | 9 | Gateau, Thibault | git config --local user.name ${USER} |
85 | 9 | Gateau, Thibault | echo -e "lorem ispum \n titi \n Authors are us \n toto" > readme.md |
86 | 9 | Gateau, Thibault | git add readme.md |
87 | 9 | Gateau, Thibault | git commit -m "We should put our names in the file !" |
88 | 9 | Gateau, Thibault | #Et la on push comme avant |
89 | 9 | Gateau, Thibault | git push origin master |
90 | 9 | Gateau, Thibault | git lg1 |
91 | 9 | Gateau, Thibault | #* 72f9bc3 - (4 seconds ago) We should put our names in the file ! - charles (HEAD, master) |
92 | 9 | Gateau, Thibault | #* 98c844b - (28 minutes ago) my third commit - charles |
93 | 9 | Gateau, Thibault | #* 327be69 - (28 minutes ago) my second commit - charles |
94 | 9 | Gateau, Thibault | #* 7562195 - (30 minutes ago) initial commit - charles |
95 | 9 | Gateau, Thibault | |
96 | 9 | Gateau, Thibault | #T3> retour Terminal3 |
97 | 10 | Gateau, Thibault | |
98 | 9 | Gateau, Thibault | USER=bob |
99 | 9 | Gateau, Thibault | cd && cd gitBob/projet |
100 | 9 | Gateau, Thibault | git config --local user.name ${USER} |
101 | 9 | Gateau, Thibault | git push origin master |
102 | 9 | Gateau, Thibault | # ! [rejected] master -> master (fetch first) |
103 | 9 | Gateau, Thibault | #error: failed to push some refs to '/home/charles/serverTestGit/projet.git/' |
104 | 9 | Gateau, Thibault | #hint: Updates were rejected because the remote contains work that you do |
105 | 9 | Gateau, Thibault | #hint: not have locally. This is usually caused by another repository pushing |
106 | 9 | Gateau, Thibault | #hint: to the same ref. You may want to first integrate the remote changes |
107 | 9 | Gateau, Thibault | #hint: (e.g., 'git pull ...') before pushing again. |
108 | 9 | Gateau, Thibault | #hint: See the 'Note about fast-forwards' in 'git push --help' for details. |
109 | 9 | Gateau, Thibault | |
110 | 9 | Gateau, Thibault | git fetch #on récupère l'état du dépot distant |
111 | 9 | Gateau, Thibault | git lg1 #on constate qu'une branche est apparue ! |
112 | 9 | Gateau, Thibault | #* 72f9bc3 - (36 minutes ago) We should put our names in the file ! - charles (origin/master, #origin/HEAD) |
113 | 9 | Gateau, Thibault | #| * 199d358 - (48 minutes ago) I want to add my name in the file! - bob (HEAD, master) |
114 | 9 | Gateau, Thibault | #|/ |
115 | 9 | Gateau, Thibault | #* 98c844b - (64 minutes ago) my third commit - charles |
116 | 9 | Gateau, Thibault | #* 327be69 - (64 minutes ago) my second commit - charles |
117 | 9 | Gateau, Thibault | #* 7562195 - (66 minutes ago) initial commit - charles |
118 | 9 | Gateau, Thibault | |
119 | 9 | Gateau, Thibault | git checkout master #en fait, ici on y est déjà... mais les infos sont instructives ! |
120 | 9 | Gateau, Thibault | #Already on 'master' |
121 | 9 | Gateau, Thibault | #Your branch and 'origin/master' have diverged, |
122 | 9 | Gateau, Thibault | #and have 1 and 1 different commit each, respectively. |
123 | 9 | Gateau, Thibault | # (use "git pull" to merge the remote branch into yours) |
124 | 9 | Gateau, Thibault | #charles@port-charles-elitebook:~/gitBob/projet$ git lg1 |
125 | 9 | Gateau, Thibault | |
126 | 9 | Gateau, Thibault | git pull |
127 | 9 | Gateau, Thibault | #Auto-merging readme.md |
128 | 9 | Gateau, Thibault | #CONFLICT (content): Merge conflict in readme.md |
129 | 9 | Gateau, Thibault | #Automatic merge failed; fix conflicts and then commit the result. |
130 | 9 | Gateau, Thibault | |
131 | 9 | Gateau, Thibault | #Et voila ! on a un conflit entre les 2 versions ! |
132 | 9 | Gateau, Thibault | #pas de pannique: |
133 | 9 | Gateau, Thibault | cat readme.md |
134 | 9 | Gateau, Thibault | #lorem ispum |
135 | 9 | Gateau, Thibault | # titi |
136 | 9 | Gateau, Thibault | #<<<<<<< HEAD |
137 | 9 | Gateau, Thibault | # Bob |
138 | 9 | Gateau, Thibault | #======= |
139 | 9 | Gateau, Thibault | # Authors are us |
140 | 9 | Gateau, Thibault | #>>>>>>> 72f9bc327dc6bcbb76de5a1fb5c78f4195ac164c |
141 | 9 | Gateau, Thibault | # toto |
142 | 9 | Gateau, Thibault | |
143 | 9 | Gateau, Thibault | #C'est plutôt clair... HEAD étant ma version (celle de Bob, et l'autre, la distante - remote - celle de Charles) |
144 | 9 | Gateau, Thibault | |
145 | 9 | Gateau, Thibault | #2 solutions: |
146 | 9 | Gateau, Thibault | #A la main : éditer readme.md, et le corriger |
147 | 9 | Gateau, Thibault | gedit readme.md |
148 | 9 | Gateau, Thibault | |
149 | 9 | Gateau, Thibault | #Avec mergetool (meld par default) cf. https://gist.github.com/karenyyng/f19ff75c60f18b4b8149 |
150 | 9 | Gateau, Thibault | #git mergetool |
151 | 9 | Gateau, Thibault | |
152 | 9 | Gateau, Thibault | #et on a plus qu'a partager cet update (avec un nouveau commit) |
153 | 9 | Gateau, Thibault | git add readme.md |
154 | 9 | Gateau, Thibault | git ci -m "adding both authors is better after all" |
155 | 9 | Gateau, Thibault | git lg1 |
156 | 9 | Gateau, Thibault | #* 878eb6a - (3 seconds ago) adding both authors is better after all - bob (HEAD, master) |
157 | 9 | Gateau, Thibault | #|\ |
158 | 9 | Gateau, Thibault | #| * 72f9bc3 - (53 minutes ago) We should put our names in the file ! - charles (origin/master, origin/HEAD) |
159 | 9 | Gateau, Thibault | #* | 199d358 - (64 minutes ago) I want to add my name in the file! - bob |
160 | 9 | Gateau, Thibault | #|/ |
161 | 9 | Gateau, Thibault | #* 98c844b - (80 minutes ago) my third commit - charles |
162 | 9 | Gateau, Thibault | #* 327be69 - (80 minutes ago) my second commit - charles |
163 | 9 | Gateau, Thibault | #* 7562195 - (82 minutes ago) initial commit - charles |
164 | 9 | Gateau, Thibault | git push origin master |
165 | 9 | Gateau, Thibault | |
166 | 9 | Gateau, Thibault | #on note qu'une branche est apparue dans le projet. Pour éviter cela, on peut utiliser l'option --rebase lors du pull... à vous d'essayer ! |
167 | 9 | Gateau, Thibault | #git pull --rebase #au bon moment évidemment ! |
168 | 9 | Gateau, Thibault | |
169 | 9 | Gateau, Thibault | |
170 | 4 | Gateau, Thibault | h1. |
171 | 4 | Gateau, Thibault | Useful links |
172 | 1 | Gateau, Thibault | |
173 | 4 | Gateau, Thibault | * example of .gitconfig: https://sourceforge.isae.fr/projects/iut_testing/repository/revisions/master/entry/.gitconfig |
174 | 5 | Gateau, Thibault | * this readme.md: https://sourceforge.isae.fr/projects/iut_testing/repository/revisions/master/entry/localGitTutorial.md |
175 | 4 | Gateau, Thibault | * tutorials: |
176 | 4 | Gateau, Thibault | - official: https://git-scm.com/docs/gittutorial |
177 | 4 | Gateau, Thibault | - interactive: https://www.katacoda.com/courses/git |
178 | 3 | Gateau, Thibault | - branching interactive: https://learngitbranching.js.org/ |
179 | 3 | Gateau, Thibault | - smartgit: https://www.syntevo.com/smartgit/download/ |
180 | 9 | Gateau, Thibault | - conflict solving https://gist.github.com/karenyyng/f19ff75c60f18b4b8149 |