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