-
Notifications
You must be signed in to change notification settings - Fork 0
/
talk.pdc
359 lines (181 loc) · 6.12 KB
/
talk.pdc
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
# Git & Chips
### git initiation
### 30.05.12
### Andreas Kundig + David Hodgetts
### made possible by "Pro Git" book
### http://git-scm.com/book
### authored by Scott Chacon
### creative commons
# what is git
* distributed version control
* ![](images/distributed.png)
# some defining features
* stores snaphots
* ![](images/snapshots.png)
* not diffs
* ![](images/snapshotsDiff.png)
* local operations possible
* git integrity (sha1)
* you only ever really add data
# local operations
* ![](images/localOperations.png)
# installation
* linux -> apt-get install git-core
* mac -> http://code.google.com/p/git-osx-installer
* mac -> homebrew -> http://mxcl.github.com/homebrew/
* windows -> http://code.google.com/p/msysgit
* windows -> http://cygwin.com
# first time configuration
* git config --global user.name "Andreas Kundig"
* git config --global user.email [email protected]
* git config --global core.editor "mate -w"
* more configs -> http://www.arthurkoziel.com/2008/05/02/git-configuration/
* git config --list
# my first repo
* git init
* git status
* git add myFile
* git commit
* git commit -m "commit message: i can haz cheeseburger"
# cloning an existing repo
* git clone [url]
* git clone git://github.com/user/repo.git
* git clone https://github.com/user/repo.git
* git clone [email protected]:git/myrepo.git
# file status
* files can be tracked (files that were in the last snapshot) or untracked
* tracked files can be unmodified, modified or staged
* ![](images/fileLifecycle.png)
* git status
* ![](images/localOperations.png)
# don't ignore me
.gitignore
~~~~~~~~~~
# a comment - this is ignored
*.a # no .a files
!lib.a # but do track lib.a, even though you're ignoring .a files above
/TODO # only ignore the root TODO file, not subdir/TODO
build/ # ignore all files in the build/ directory
doc/*.txt # ignore doc/notes.txt, but not doc/server/arch.txt
~~~~~~~~~~
# skip the staging area
* git commit -am "commit all changes on tracked files but not any new files"
# mv - rm
* git mv oldFilename newFilename
* git rm file # removes from repo and working directory
* git rm --cached file # only removes from repo (file no longer tracked but on working dir)
# viewing the commit history
* git log
* git log -p -2
* git log --stat
* git log --pretty=oneline
* git log --pretty=format:"%h %s" --graph
* git log --graph --decorate --oneline
# undoing stuff
* git commit --amend
* unstaging staged file -> check out git status -> git reset HEAD fileName
* unmodifying a modified file (not staged) -> look at git status -> git checkout -- fileName
# Git Branching
* single commit
* ![](images/singleCommitTree.png)
* we add some commits
* ![](images/multipleCommits.png)
# so a branch is ...
* a movable pointer to one of these commits
* default branch is called "master"
* ![](images/branchPointer.png)
# creating a new branch means ...
* adding a new movable pointer
* git branch testing
* ![](images/newBranch.png)
# ok but how does Git know on which branch i am?
* it uses a special pointer called HEAD
* ![](images/headOnMaster.png)
* if we change branches: git checkout testing
* ![](images/headOnTesting.png)
# HEAD moves with the new commits on current branch
* modify file on testing + commit on testing
* ![](images/headMovedOnTesting.png)
* git checkout master
* ![](images/headBackOnMaster.png)
# alternate history
* let's do some work on master and commit
* ![](images/headMovedOnMaster.png)
* mmm but how do i reconcile my diverging branches? ...
# merging
* a new project on my supersite for my superstartup
* ![](images/supersiteStart.png)
* let's work on issue 53
* git checkout -b iss53 (same as "git branch iss53" followed by "git checkout iss53")
* ![](images/createdIss53.png)
* do some work and commit
* ![](images/commitOnIss53.png)
# oh boy there is an urgent fix required on the production version (master)
* commit your work on iss53
* checkout master
* create a hotfix branch on master -> git checkout -b hotfix
* do the fix and commit
* ![](images/hotfixBranch.png)
# if hotfix is approved we can merge it back into master
* git checkout master
* git merge hotfix
* ![](images/fastForward.png)
* master is "fast forwarded" (the pointer has just to move point to the same commit as hotfix)
* hotfix branch no longer needed -> git branch -d hotfix
# get back to work on issue 53
* git checkout iss53
* do work and commit
* ![](images/moreWorkOnIss53.png)
# we assume work is done on issue 53 we want to merge work back into master
* git checkout master
* git merge iss53
* Fast forward not possible
* ![](images/moreWorkOnIss53.png)
# git does a 3 way merge
* (master, iss53 and first common ancestor)
* ![](images/3wayMerge.png)
* result:
* ![](images/3wayMergeResult.png)
# merge conflicts
* ![](images/3wayMerge.png)
# branch management
* git branch
* git branch -a
* git branch -r
* git branch --merged (shows branches that are already merged on current branch)
* delete branch: git branch -d
# remotes and remote branches
* git clone supersite
* ![](images/gitClone.png)
* Remote branches act as bookmarks to remind you where the branches on your remote repositories were the last time you connected to them.
* remote/branch
* origin/master
* pierre/development
# remote management
* git remote
* git remote show origin
* git remote add repoOfAndreas git://github.com/repoOfAndreas.git
* git remote show repoOfAndreas
* git remote rename oldName newName
* git remote rm repoOfAndreas (removes remote named repoOfAndreas)
# how does it work?
* someone works on the projet and pushes to origin
* ![](images/pushOnOrigin.png)
* histories diverge, again...
# sync with remote
* git fetch origin
* ![](images/gitFetch.png)
* git log origin/master
* git diff master origin/master
* git merge origin/master
# you can also use Pull instead of Fetch
* pull does :
* git fetch + git merge into current branch
* but it's a not really the git way
# Push your work
* git push
* git push remoteName branchName
* git push origin master
# what's next
* http://git-scm.com/documentation/external-links
* stackoverflow