@@ -50,6 +50,35 @@ Everybody uses these commands to feed and care git repositories.
5050
5151 * gitlink:git-repack[1] to pack loose objects for efficiency.
5252
53+ Examples
54+ ~~~~~~~~
55+
56+ Check health and remove cruft::
57+ +
58+ ------------
59+ $ git fsck-objects <1>
60+ $ git prune
61+ $ git count-objects <2>
62+ $ git repack <3>
63+ $ git prune <4>
64+
65+ <1> running without "--full" is usually cheap and assures the
66+ repository health reasonably well.
67+ <2> check how many loose objects there are and how much
68+ diskspace is wasted by not repacking.
69+ <3> without "-a" repacks incrementally. repacking every 4-5MB
70+ 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::
75+ +
76+ ------------
77+ $ git repack -a -d <1>
78+ $ git prune
79+ ------------
80+
81+
5382Individual Developer (Standalone)[[Individual Developer (Standalone)]]
5483----------------------------------------------------------------------
5584
@@ -88,7 +117,8 @@ following commands.
88117Examples
89118~~~~~~~~
90119
91- * Extract a tarball and create a working tree and a new repository to keep track of it.
120+ Extract a tarball and create a working tree and a new repository to keep track of it::
121+ +
92122------------
93123$ tar zxf frotz.tar.gz
94124$ cd frotz
@@ -101,7 +131,8 @@ $ git tag v2.43 <2>
101131<2> make a lightweight, unannotated tag.
102132------------
103133
104- * Create a topic branch and develop
134+ Create a topic branch and develop::
135+ +
105136------------
106137$ git checkout -b alsa-audio <1>
107138$ edit/compile/test
@@ -158,12 +189,13 @@ addition to the ones needed by a standalone developer.
158189Examples
159190~~~~~~~~
160191
161- * Clone the upstream and work on it. Feed changes to upstream.
192+ Clone the upstream and work on it. Feed changes to upstream::
193+ +
162194------------
163195$ git clone git://git.kernel.org/pub/scm/.../torvalds/linux-2.6 my2.6
164196$ cd my2.6
165197$ edit/compile/test; git commit -a -s <1>
166- $ git format-patch master <2>
198+ $ git format-patch origin <2>
167199$ git pull <3>
168200$ git whatchanged -p ORIG_HEAD.. arch/i386 include/asm-i386 <4>
169201$ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <5>
@@ -180,7 +212,8 @@ area we are interested in.
180212<7> garbage collect leftover objects from reverted pull.
181213------------
182214
183- * Branch off of a specific tag.
215+ Branch off of a specific tag::
216+ +
184217------------
185218$ git checkout -b private2.6.14 v2.6.14 <1>
186219$ edit/compile/test; git commit -a
@@ -219,7 +252,8 @@ commands in addition to the ones needed by participants.
219252Examples
220253~~~~~~~~
221254
222- * My typical GIT day.
255+ My typical GIT day::
256+ +
223257------------
224258$ git status <1>
225259$ git show-branch <2>
@@ -231,16 +265,17 @@ $ git checkout master
231265$ git am -3 -i -s -u ./+to-apply <4>
232266$ compile/test
233267$ git checkout -b hold/linus && git am -3 -i -s -u ./+hold-linus <5>
234- $ git checkout pu && git reset --hard master <6>
235- $ git pull . topic/one topic/two && git pull . hold/linus <7>
268+ $ git checkout topic/one && git rebase master <6>
269+ $ git checkout pu && git reset --hard master <7>
270+ $ git pull . topic/one topic/two && git pull . hold/linus <8>
236271$ git fetch ko master:refs/tags/ko-master &&
237- git show-branch master ko-master <8 >
238- $ git push ko <9 >
272+ git show-branch master ko-master <9 >
273+ $ git push ko <10 >
239274$ git checkout maint
240- $ git cherry-pick master~4 <10 >
275+ $ git cherry-pick master~4 <11 >
241276$ compile/test
242- $ git tag -s -m 'GIT 0.99.9x' v0.99.9x <11 >
243- $ git push ko v0.99.9x <12 >
277+ $ git tag -s -m 'GIT 0.99.9x' v0.99.9x <12 >
278+ $ git push ko v0.99.9x <13 >
244279
245280<1> see what I was in the middle of doing, if any.
246281<2> see what topic branches I have and think about how ready
@@ -250,14 +285,16 @@ that are not quite ready.
250285<4> apply them, interactively, with my sign-offs.
251286<5> create topic branch as needed and apply, again with my
252287sign-offs.
253- <6> restart "pu" every time from the master.
254- <7> and bundle topic branches still cooking.
255- <8> make sure I did not accidentally rewound master beyond what I
288+ <6> rebase internal topic branch that has not been merged to the
289+ master, nor exposed as a part of a stable branch.
290+ <7> restart "pu" every time from the master.
291+ <8> and bundle topic branches still cooking.
292+ <9> make sure I did not accidentally rewound master beyond what I
256293already pushed out.
257- <9 > push out the bleeding edge.
258- <10 > backport a critical fix.
259- <11 > create a signed tag.
260- <12 > push the tag 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.
261298------------
262299
263300
@@ -276,3 +313,25 @@ and maintain access to the repository by developers.
276313 * link:howto/update-hook-example.txt[update hook howto] has a
277314 good example of managing a shared central repository.
278315
316+
317+ Examples
318+ ~~~~~~~~
319+
320+ Run git-daemon to serve /pub/scm from inetd::
321+ +
322+ ------------
323+ $ grep git /etc/inet.conf
324+ git stream tcp nowait nobody /usr/bin/git-daemon git-daemon --inetd --syslog --export-all /pub/scm
325+ ------------
326+
327+ Give push/pull only access to developers::
328+ +
329+ ------------
330+ $ grep git /etc/shells
331+ /usr/bin/git-shell
332+ $ grep git /etc/passwd
333+ alice:x:1000:1000::/home/alice:/usr/bin/git-shell
334+ bob:x:1001:1001::/home/bob:/usr/bin/git-shell
335+ cindy:x:1002:1002::/home/cindy:/usr/bin/git-shell
336+ david:x:1003:1003::/home/david:/usr/bin/git-shell
337+ ------------
0 commit comments