Everyday: a bit more examples.
Talk about the following as well: * git fetch --tags * Use of "git push" as a one-man distributed development vehicle. * Show example of remotes file for pulling and pushing. * Annotate git-shell setup. * Using Carl's update hook in a CVS-style shared repository. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Dec 14, 2005 at 00:42 UTC
01f49e3453d9960fec62d93bc3a66784f1be4c26
1 file changed
+118
-29
Documentation/everyday.txt
+118
-29
@@ -53,7 +53,7 @@ Everybody uses these commands to feed and care git repositories.
53
Examples
54
~~~~~~~~
55
56
-Check health and remove cruft::
56
+Check health and remove cruft.::
57
+
58
------------
59
$ git fsck-objects <1>
@@ -71,11 +71,14 @@ of loose objects accumulation may be a good rule of thumb.
71
<4> after repack, prune removes the duplicate loose objects.
72
------------
73
74
-Repack a small project into single pack::
74
+Repack a small project into single pack.::
75
+
76
------------
77
$ git repack -a -d <1>
78
$ git prune
79
+
80
+<1> pack all the objects reachable from the refs into one pack
81
+and remove unneeded other packs
82
------------
83
84
@@ -117,7 +120,7 @@ following commands.
120
Examples
121
~~~~~~~~
122
120
-Extract a tarball and create a working tree and a new repository to keep track of it::
123
+Extract a tarball and create a working tree and a new repository to keep track of it.::
124
+
125
------------
126
$ tar zxf frotz.tar.gz
@@ -131,7 +134,7 @@ $ git tag v2.43 <2>
134
<2> make a lightweight, unannotated tag.
135
------------
136
134
-Create a topic branch and develop::
137
+Create a topic branch and develop.::
138
+
139
------------
140
$ git checkout -b alsa-audio <1>
@@ -163,7 +166,8 @@ modification will be caught if you do "commit -a" later.
166
you originally wrote.
167
<9> switch to the master branch.
168
<10> merge a topic branch into your master branch
166
-<11> or --since='aug 1', --max-count=10
169
+<11> review commit logs; other forms to limit output can be
170
+combined and include --max-count=10 (show 10 commits), --until='2005-12-10'.
171
<12> view only the changes that touch what's in curses/
172
directory, since v2.43 tag.
173
------------
@@ -176,20 +180,22 @@ A developer working as a participant in a group project needs to
180
learn how to communicate with others, and uses these commands in
181
addition to the ones needed by a standalone developer.
182
179
- * gitlink:git-pull[1] from "origin" to keep up-to-date with
180
- the upstream.
183
+ * gitlink:git-clone[1] from the upstream to prime your local
184
+ repository.
185
+
186
+ * gitlink:git-pull[1] and gitlink:git-fetch[1] from "origin"
187
+ to keep up-to-date with the upstream.
188
182
- * gitlink:git-push[1] to shared repository if you adopt CVS
189
+ * gitlink:git-push[1] to shared repository, if you adopt CVS
190
style shared repository workflow.
191
192
* gitlink:git-format-patch[1] to prepare e-mail submission, if
193
you adopt Linux kernel-style public forum workflow.
194
188
-
195
Examples
196
~~~~~~~~
197
192
-Clone the upstream and work on it. Feed changes to upstream::
198
+Clone the upstream and work on it. Feed changes to upstream.::
199
+
200
------------
201
$ git clone git://git.kernel.org/pub/scm/.../torvalds/linux-2.6 my2.6
@@ -201,6 +207,7 @@ $ git whatchanged -p ORIG_HEAD.. arch/i386 include/asm-i386 <4>
207
$ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <5>
208
$ git reset --hard ORIG_HEAD <6>
209
$ git prune <7>
210
+$ git fetch --tags <8>
211
212
<1> repeat as needed.
213
<2> extract patches from your branch for e-mail submission.
@@ -210,9 +217,42 @@ area we are interested in.
217
<5> fetch from a specific branch from a specific repository and and merge.
218
<6> revert the pull.
219
<7> garbage collect leftover objects from reverted pull.
220
+<8> from time to time, obtain official tags from the "origin"
221
+and store them under .git/refs/tags/.
222
+------------
223
+
224
+
225
+Push into another repository.::
226
++
227
+------------
228
+satellite$ git clone mothership:frotz/.git frotz <1>
229
+satellite$ cd frotz
230
+satellite$ cat .git/remotes/origin <2>
231
+URL: mothership:frotz/.git
232
+Pull: master:origin
233
+satellite$ echo 'Push: master:satellite' >>.git/remotes/origin <3>
234
+satellite$ edit/compile/test/commit
235
+satellite$ git push origin <4>
236
+
237
+mothership$ cd frotz
238
+mothership$ git checkout master
239
+mothership$ git pull . satellite <5>
240
+
241
+<1> mothership machine has a frotz repository under your home
242
+directory; clone from it to start a repository on the satellite
243
+machine.
244
+<2> clone creates this file by default. It arranges "git pull"
245
+to fetch and store the master branch head of mothership machine
246
+to local "origin" branch.
247
+<3> arrange "git push" to push local "master" branch to
248
+"satellite" branch of the mothership machine.
249
+<4> push will stash our work away on "satellite" branch on the
250
+mothership machine. You could use this as a back-up method.
251
+<5> on mothership machine, merge the work done on the satellite
252
+machine into the master branch.
253
------------
254
215
-Branch off of a specific tag::
255
+Branch off of a specific tag.::
256
+
257
------------
258
$ git checkout -b private2.6.14 v2.6.14 <1>
@@ -252,7 +292,7 @@ commands in addition to the ones needed by participants.
292
Examples
293
~~~~~~~~
294
255
-My typical GIT day::
295
+My typical GIT day.::
296
+
297
------------
298
$ git status <1>
@@ -268,13 +308,12 @@ $ git checkout -b hold/linus && git am -3 -i -s -u ./+hold-linus <5>
308
$ git checkout topic/one && git rebase master <6>
309
$ git checkout pu && git reset --hard master <7>
310
$ git pull . topic/one topic/two && git pull . hold/linus <8>
271
-$ git fetch ko master:refs/tags/ko-master &&
272
- git show-branch master ko-master <9>
273
-$ git push ko <10>
311
$ git checkout maint
275
-$ git cherry-pick master~4 <11>
312
+$ git cherry-pick master~4 <9>
313
$ compile/test
277
-$ git tag -s -m 'GIT 0.99.9x' v0.99.9x <12>
314
+$ git tag -s -m 'GIT 0.99.9x' v0.99.9x <10>
315
+$ git fetch ko && git show-branch master maint 'tags/ko-*' <11>
316
+$ git push ko <12>
317
$ git push ko v0.99.9x <13>
318
319
<1> see what I was in the middle of doing, if any.
@@ -289,12 +328,20 @@ sign-offs.
328
master, nor exposed as a part of a stable branch.
329
<7> restart "pu" every time from the master.
330
<8> and bundle topic branches still cooking.
292
-<9> make sure I did not accidentally rewound master beyond what I
293
-already pushed out.
294
-<10> push out the bleeding edge.
295
-<11> backport a critical fix.
296
-<12> create a signed tag.
297
-<13> push the tag out.
331
+<9> backport a critical fix.
332
+<10> create a signed tag.
333
+<11> make sure I did not accidentally rewound master beyond what I
334
+already pushed out. "ko" shorthand points at the repository I have
335
+at kernel.org, and looks like this:
336
+$ cat .git/remotes/ko
337
+URL: kernel.org:/pub/scm/git/git.git
338
+Pull: master:refs/tags/ko-master
339
+Pull: maint:refs/tags/ko-maint
340
+Push: master
341
+Push: +pu
342
+Push: maint
343
+<12> push out the bleeding edge.
344
+<13> push the tag out, too.
345
------------
346
347
@@ -317,21 +364,63 @@ and maintain access to the repository by developers.
364
Examples
365
~~~~~~~~
366
320
-Run git-daemon to serve /pub/scm from inetd::
367
+Run git-daemon to serve /pub/scm from inetd.::
368
+
369
------------
370
$ grep git /etc/inet.conf
324
-git stream tcp nowait nobody /usr/bin/git-daemon git-daemon --inetd --syslog --export-all /pub/scm
371
+git stream tcp nowait nobody \
372
+ /usr/bin/git-daemon git-daemon --inetd --syslog --export-all /pub/scm
373
------------
374
++
375
+The actual configuration line should be on one line.
376
327
-Give push/pull only access to developers::
377
+Give push/pull only access to developers.::
378
+
379
------------
330
-$ grep git /etc/shells
331
-/usr/bin/git-shell
332
-$ grep git /etc/passwd
380
+$ grep git /etc/passwd <1>
381
alice:x:1000:1000::/home/alice:/usr/bin/git-shell
382
bob:x:1001:1001::/home/bob:/usr/bin/git-shell
383
cindy:x:1002:1002::/home/cindy:/usr/bin/git-shell
384
david:x:1003:1003::/home/david:/usr/bin/git-shell
385
+$ grep git /etc/shells <2>
386
+/usr/bin/git-shell
387
+
388
+<1> log-in shell is set to /usr/bin/git-shell, which does not
389
+allow anything but "git push" and "git pull". The users should
390
+get an ssh access to the machine.
391
+<2> in many distributions /etc/shells needs to list what is used
392
+as the login shell.
393
+------------
394
+
395
+CVS-style shared repository.::
396
++
397
+------------
398
+$ grep git /etc/group <1>
399
+git:x:9418:alice,bob,cindy,david
400
+$ cd /home/devo.git
401
+$ ls -l <2>
402
+ lrwxrwxrwx 1 david git 17 Dec 4 22:40 HEAD -> refs/heads/master
403
+ drwxrwsr-x 2 david git 4096 Dec 4 22:40 branches
404
+ -rw-rw-r-- 1 david git 84 Dec 4 22:40 config
405
+ -rw-rw-r-- 1 david git 58 Dec 4 22:40 description
406
+ drwxrwsr-x 2 david git 4096 Dec 4 22:40 hooks
407
+ -rw-rw-r-- 1 david git 37504 Dec 4 22:40 index
408
+ drwxrwsr-x 2 david git 4096 Dec 4 22:40 info
409
+ drwxrwsr-x 4 david git 4096 Dec 4 22:40 objects
410
+ drwxrwsr-x 4 david git 4096 Nov 7 14:58 refs
411
+ drwxrwsr-x 2 david git 4096 Dec 4 22:40 remotes
412
+$ ls -l hooks/update <3>
413
+ -r-xr-xr-x 1 david git 3536 Dec 4 22:40 update
414
+$ cat info/allowed-users <4>
415
+refs/heads/master alice\|cindy
416
+refs/heads/doc-update bob
417
+refs/tags/v[0-9]* david
418
+
419
+<1> place the developers into the same git group.
420
+<2> and make the shared repository writable by the group.
421
+<3> use update-hook example by Carl from Documentation/howto/
422
+for branch policy control.
423
+<4> alice and cindy can push into master, only bob can push into doc-update.
424
+david is the release manager and is the only person who can
425
+create and push version tags.
426
------------