blob: 1bd919f92bdd053cdfde7678ae6528f91513bc45 [file] [log] [blame]
Philip Oakley992cb202014-10-10 22:25:35 +01001giteveryday(7)
Junio C Hamanof3f38c72015-10-22 10:14:44 -07002==============
Philip Oakley992cb202014-10-10 22:25:35 +01003
4NAME
5----
6giteveryday - A useful minimum set of commands for Everyday Git
7
8SYNOPSIS
9--------
10
Thomas Ackermann48a8c262013-01-21 20:16:20 +010011Everyday Git With 20 Commands Or So
Junio C Hamanodb9536c2005-12-09 23:07:29 -080012
Philip Oakley992cb202014-10-10 22:25:35 +010013DESCRIPTION
14-----------
Junio C Hamanodb9536c2005-12-09 23:07:29 -080015
Philip Oakley992cb202014-10-10 22:25:35 +010016Git users can broadly be grouped into four categories for the purposes of
17describing here a small set of useful command for everyday Git.
Junio C Hamanodb9536c2005-12-09 23:07:29 -080018
Philip Oakley992cb202014-10-10 22:25:35 +010019* <<STANDALONE,Individual Developer (Standalone)>> commands are essential
20 for anybody who makes a commit, even for somebody who works alone.
Junio C Hamanodb9536c2005-12-09 23:07:29 -080021
Philip Oakley992cb202014-10-10 22:25:35 +010022* If you work with other people, you will need commands listed in
23 the <<PARTICIPANT,Individual Developer (Participant)>> section as well.
24
25* People who play the <<INTEGRATOR,Integrator>> role need to learn some
26 more commands in addition to the above.
27
28* <<ADMINISTRATION,Repository Administration>> commands are for system
29 administrators who are responsible for the care and feeding
30 of Git repositories.
Junio C Hamanodb9536c2005-12-09 23:07:29 -080031
32
Philip Oakley992cb202014-10-10 22:25:35 +010033Individual Developer (Standalone)[[STANDALONE]]
34-----------------------------------------------
Junio C Hamanodb9536c2005-12-09 23:07:29 -080035
36A standalone individual developer does not exchange patches with
Horst von Brand7872b182006-05-29 17:11:28 -040037other people, and works alone in a single repository, using the
Junio C Hamanodb9536c2005-12-09 23:07:29 -080038following commands.
39
Anders Kaseorgbce02c12009-10-21 16:02:48 -040040 * linkgit:git-init[1] to create a new repository.
41
Dan McGee5162e692007-12-29 00:20:38 -060042 * linkgit:git-log[1] to see what happened.
Junio C Hamanodb9536c2005-12-09 23:07:29 -080043
Nguyễn Thái Ngọc Duy328c6cb2019-03-29 17:39:19 +070044 * linkgit:git-switch[1] and linkgit:git-branch[1] to switch
Junio C Hamanodb9536c2005-12-09 23:07:29 -080045 branches.
46
Dan McGee5162e692007-12-29 00:20:38 -060047 * linkgit:git-add[1] to manage the index file.
Junio C Hamano44db1362005-12-12 16:20:21 -080048
Dan McGee5162e692007-12-29 00:20:38 -060049 * linkgit:git-diff[1] and linkgit:git-status[1] to see what
Junio C Hamano44db1362005-12-12 16:20:21 -080050 you are in the middle of doing.
Junio C Hamanodb9536c2005-12-09 23:07:29 -080051
Dan McGee5162e692007-12-29 00:20:38 -060052 * linkgit:git-commit[1] to advance the current branch.
Junio C Hamanodb9536c2005-12-09 23:07:29 -080053
Nguyễn Thái Ngọc Duy80f537f2019-04-25 16:45:58 +070054 * linkgit:git-restore[1] to undo changes.
Junio C Hamanodb9536c2005-12-09 23:07:29 -080055
Dan McGee5162e692007-12-29 00:20:38 -060056 * linkgit:git-merge[1] to merge between local branches.
Junio C Hamanodb9536c2005-12-09 23:07:29 -080057
Dan McGee5162e692007-12-29 00:20:38 -060058 * linkgit:git-rebase[1] to maintain topic branches.
Junio C Hamanodb9536c2005-12-09 23:07:29 -080059
Philip Oakley992cb202014-10-10 22:25:35 +010060 * linkgit:git-tag[1] to mark a known point.
Junio C Hamanodb9536c2005-12-09 23:07:29 -080061
Junio C Hamano44db1362005-12-12 16:20:21 -080062Examples
63~~~~~~~~
64
Junio C Hamano268b8272006-12-26 22:42:33 -080065Use a tarball as a starting point for a new repository.::
Junio C Hamano1e2ccd32005-12-12 23:24:06 -080066+
Junio C Hamano44db1362005-12-12 16:20:21 -080067------------
68$ tar zxf frotz.tar.gz
69$ cd frotz
David Aguilar3e5970a2009-03-22 02:15:13 -070070$ git init
Junio C Hamano180c4742005-12-12 18:29:53 -080071$ git add . <1>
Sergei Organovd336fc02007-11-02 20:12:57 +030072$ git commit -m "import of frotz source tree."
Junio C Hamano180c4742005-12-12 18:29:53 -080073$ git tag v2.43 <2>
Sean Estabrooks48aeecd2006-04-28 09:15:05 -040074------------
75+
Junio C Hamano180c4742005-12-12 18:29:53 -080076<1> add everything under the current directory.
77<2> make a lightweight, unannotated tag.
Junio C Hamano44db1362005-12-12 16:20:21 -080078
Junio C Hamano01f49e32005-12-14 00:42:45 -080079Create a topic branch and develop.::
Junio C Hamano1e2ccd32005-12-12 23:24:06 -080080+
Junio C Hamano44db1362005-12-12 16:20:21 -080081------------
Nguyễn Thái Ngọc Duy328c6cb2019-03-29 17:39:19 +070082$ git switch -c alsa-audio <1>
Junio C Hamano44db1362005-12-12 16:20:21 -080083$ edit/compile/test
Nguyễn Thái Ngọc Duy80f537f2019-04-25 16:45:58 +070084$ git restore curses/ux_audio_oss.c <2>
Junio C Hamano180c4742005-12-12 18:29:53 -080085$ git add curses/ux_audio_alsa.c <3>
Junio C Hamano44db1362005-12-12 16:20:21 -080086$ edit/compile/test
Junio C Hamano268b8272006-12-26 22:42:33 -080087$ git diff HEAD <4>
Junio C Hamano180c4742005-12-12 18:29:53 -080088$ git commit -a -s <5>
89$ edit/compile/test
Philip Oakley992cb202014-10-10 22:25:35 +010090$ git diff HEAD^ <6>
91$ git commit -a --amend <7>
Nguyễn Thái Ngọc Duy328c6cb2019-03-29 17:39:19 +070092$ git switch master <8>
Philip Oakley992cb202014-10-10 22:25:35 +010093$ git merge alsa-audio <9>
94$ git log --since='3 days ago' <10>
95$ git log v2.43.. curses/ <11>
Sean Estabrooks48aeecd2006-04-28 09:15:05 -040096------------
97+
Junio C Hamano180c4742005-12-12 18:29:53 -080098<1> create a new topic branch.
Junio C Hamano268b8272006-12-26 22:42:33 -080099<2> revert your botched changes in `curses/ux_audio_oss.c`.
Thomas Ackermann2de9b712013-01-21 20:17:53 +0100100<3> you need to tell Git if you added a new file; removal and
Junio C Hamano268b8272006-12-26 22:42:33 -0800101modification will be caught if you do `git commit -a` later.
Junio C Hamano180c4742005-12-12 18:29:53 -0800102<4> to see what changes you are committing.
Philip Oakley992cb202014-10-10 22:25:35 +0100103<5> commit everything, as you have tested, with your sign-off.
104<6> look at all your changes including the previous commit.
105<7> amend the previous commit, adding all your new changes,
106using your original message.
107<8> switch to the master branch.
108<9> merge a topic branch into your master branch.
109<10> review commit logs; other forms to limit output can be
110combined and include `-10` (to show up to 10 commits),
Jeff King6cf378f2012-04-26 04:51:57 -0400111`--until=2005-12-10`, etc.
Philip Oakley992cb202014-10-10 22:25:35 +0100112<11> view only the changes that touch what's in `curses/`
Junio C Hamano268b8272006-12-26 22:42:33 -0800113directory, since `v2.43` tag.
Junio C Hamano44db1362005-12-12 16:20:21 -0800114
115
Philip Oakley992cb202014-10-10 22:25:35 +0100116Individual Developer (Participant)[[PARTICIPANT]]
117-------------------------------------------------
Junio C Hamanodb9536c2005-12-09 23:07:29 -0800118
119A developer working as a participant in a group project needs to
120learn how to communicate with others, and uses these commands in
121addition to the ones needed by a standalone developer.
122
Dan McGee5162e692007-12-29 00:20:38 -0600123 * linkgit:git-clone[1] from the upstream to prime your local
Junio C Hamano01f49e32005-12-14 00:42:45 -0800124 repository.
Junio C Hamanodb9536c2005-12-09 23:07:29 -0800125
Dan McGee5162e692007-12-29 00:20:38 -0600126 * linkgit:git-pull[1] and linkgit:git-fetch[1] from "origin"
Junio C Hamano01f49e32005-12-14 00:42:45 -0800127 to keep up-to-date with the upstream.
128
Dan McGee5162e692007-12-29 00:20:38 -0600129 * linkgit:git-push[1] to shared repository, if you adopt CVS
Junio C Hamanodb9536c2005-12-09 23:07:29 -0800130 style shared repository workflow.
131
Dan McGee5162e692007-12-29 00:20:38 -0600132 * linkgit:git-format-patch[1] to prepare e-mail submission, if
Junio C Hamanodb9536c2005-12-09 23:07:29 -0800133 you adopt Linux kernel-style public forum workflow.
134
Philip Oakley992cb202014-10-10 22:25:35 +0100135 * linkgit:git-send-email[1] to send your e-mail submission without
136 corruption by your MUA.
137
138 * linkgit:git-request-pull[1] to create a summary of changes
139 for your upstream to pull.
140
141
Junio C Hamano44db1362005-12-12 16:20:21 -0800142Examples
143~~~~~~~~
144
Junio C Hamano01f49e32005-12-14 00:42:45 -0800145Clone the upstream and work on it. Feed changes to upstream.::
Junio C Hamano1e2ccd32005-12-12 23:24:06 -0800146+
Junio C Hamano44db1362005-12-12 16:20:21 -0800147------------
148$ git clone git://git.kernel.org/pub/scm/.../torvalds/linux-2.6 my2.6
149$ cd my2.6
Nguyễn Thái Ngọc Duy328c6cb2019-03-29 17:39:19 +0700150$ git switch -c mine master <1>
Philip Oakley992cb202014-10-10 22:25:35 +0100151$ edit/compile/test; git commit -a -s <2>
152$ git format-patch master <3>
153$ git send-email --to="person <email@example.com>" 00*.patch <4>
Nguyễn Thái Ngọc Duy328c6cb2019-03-29 17:39:19 +0700154$ git switch master <5>
Philip Oakley992cb202014-10-10 22:25:35 +0100155$ git pull <6>
156$ git log -p ORIG_HEAD.. arch/i386 include/asm-i386 <7>
157$ git ls-remote --heads http://git.kernel.org/.../jgarzik/libata-dev.git <8>
158$ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <9>
159$ git reset --hard ORIG_HEAD <10>
160$ git gc <11>
Sean Estabrooks48aeecd2006-04-28 09:15:05 -0400161------------
162+
Philip Oakley992cb202014-10-10 22:25:35 +0100163<1> checkout a new branch `mine` from master.
164<2> repeat as needed.
165<3> extract patches from your branch, relative to master,
166<4> and email them.
167<5> return to `master`, ready to see what's new
168<6> `git pull` fetches from `origin` by default and merges into the
Junio C Hamanod8081112005-12-18 12:11:27 -0800169current branch.
Philip Oakley992cb202014-10-10 22:25:35 +0100170<7> immediately after pulling, look at the changes done upstream
Junio C Hamanod8081112005-12-18 12:11:27 -0800171since last time we checked, only in the
Junio C Hamano180c4742005-12-12 18:29:53 -0800172area we are interested in.
Philip Oakley992cb202014-10-10 22:25:35 +0100173<8> check the branch names in an external repository (if not known).
174<9> fetch from a specific branch `ALL` from a specific repository
175and merge it.
176<10> revert the pull.
177<11> garbage collect leftover objects from reverted pull.
Junio C Hamano44db1362005-12-12 16:20:21 -0800178
Junio C Hamano01f49e32005-12-14 00:42:45 -0800179
180Push into another repository.::
181+
182------------
Junio C Hamano268b8272006-12-26 22:42:33 -0800183satellite$ git clone mothership:frotz frotz <1>
Junio C Hamano01f49e32005-12-14 00:42:45 -0800184satellite$ cd frotz
Tom Princee0d10e12007-01-28 16:16:53 -0800185satellite$ git config --get-regexp '^(remote|branch)\.' <2>
Junio C Hamano268b8272006-12-26 22:42:33 -0800186remote.origin.url mothership:frotz
187remote.origin.fetch refs/heads/*:refs/remotes/origin/*
188branch.master.remote origin
189branch.master.merge refs/heads/master
Tom Princee0d10e12007-01-28 16:16:53 -0800190satellite$ git config remote.origin.push \
Philip Oakley992cb202014-10-10 22:25:35 +0100191 +refs/heads/*:refs/remotes/satellite/* <3>
Junio C Hamano01f49e32005-12-14 00:42:45 -0800192satellite$ edit/compile/test/commit
193satellite$ git push origin <4>
194
195mothership$ cd frotz
Nguyễn Thái Ngọc Duy328c6cb2019-03-29 17:39:19 +0700196mothership$ git switch master
Junio C Hamano268b8272006-12-26 22:42:33 -0800197mothership$ git merge satellite/master <5>
Sean Estabrooks48aeecd2006-04-28 09:15:05 -0400198------------
199+
Junio C Hamano01f49e32005-12-14 00:42:45 -0800200<1> mothership machine has a frotz repository under your home
201directory; clone from it to start a repository on the satellite
202machine.
Junio C Hamano268b8272006-12-26 22:42:33 -0800203<2> clone sets these configuration variables by default.
204It arranges `git pull` to fetch and store the branches of mothership
Matthieu Moybc6dafc2010-11-02 16:31:22 +0100205machine to local `remotes/origin/*` remote-tracking branches.
Philip Oakley992cb202014-10-10 22:25:35 +0100206<3> arrange `git push` to push all local branches to
207their corresponding branch of the mothership machine.
208<4> push will stash all our work away on `remotes/satellite/*`
209remote-tracking branches on the mothership machine. You could use this
210as a back-up method. Likewise, you can pretend that mothership
211"fetched" from you (useful when access is one sided).
Junio C Hamano01f49e32005-12-14 00:42:45 -0800212<5> on mothership machine, merge the work done on the satellite
213machine into the master branch.
Junio C Hamano01f49e32005-12-14 00:42:45 -0800214
215Branch off of a specific tag.::
Junio C Hamano1e2ccd32005-12-12 23:24:06 -0800216+
Junio C Hamano44db1362005-12-12 16:20:21 -0800217------------
Nguyễn Thái Ngọc Duy328c6cb2019-03-29 17:39:19 +0700218$ git switch -c private2.6.14 v2.6.14 <1>
Junio C Hamano44db1362005-12-12 16:20:21 -0800219$ edit/compile/test; git commit -a
220$ git checkout master
Philip Oakley992cb202014-10-10 22:25:35 +0100221$ git cherry-pick v2.6.14..private2.6.14 <2>
Sean Estabrooks48aeecd2006-04-28 09:15:05 -0400222------------
223+
Junio C Hamano44db1362005-12-12 16:20:21 -0800224<1> create a private branch based on a well known (but somewhat behind)
225tag.
Junio C Hamano268b8272006-12-26 22:42:33 -0800226<2> forward port all changes in `private2.6.14` branch to `master` branch
Philip Oakley992cb202014-10-10 22:25:35 +0100227without a formal "merging". Or longhand +
228`git format-patch -k -m --stdout v2.6.14..private2.6.14 |
229 git am -3 -k`
Junio C Hamano44db1362005-12-12 16:20:21 -0800230
Philip Oakley992cb202014-10-10 22:25:35 +0100231An alternate participant submission mechanism is using the
232`git request-pull` or pull-request mechanisms (e.g as used on
233GitHub (www.github.com) to notify your upstream of your
234contribution.
Junio C Hamano44db1362005-12-12 16:20:21 -0800235
Philip Oakley992cb202014-10-10 22:25:35 +0100236Integrator[[INTEGRATOR]]
Junio C Hamanodb9536c2005-12-09 23:07:29 -0800237------------------------
238
239A fairly central person acting as the integrator in a group
240project receives changes made by others, reviews and integrates
241them and publishes the result for others to use, using these
242commands in addition to the ones needed by participants.
243
Philip Oakley992cb202014-10-10 22:25:35 +0100244This section can also be used by those who respond to `git
245request-pull` or pull-request on GitHub (www.github.com) to
Ville Skyttä928f0ab2018-06-22 09:50:37 +0300246integrate the work of others into their history. A sub-area
Philip Oakley992cb202014-10-10 22:25:35 +0100247lieutenant for a repository will act both as a participant and
248as an integrator.
249
250
Dan McGee5162e692007-12-29 00:20:38 -0600251 * linkgit:git-am[1] to apply patches e-mailed in from your
Junio C Hamanodb9536c2005-12-09 23:07:29 -0800252 contributors.
253
Dan McGee5162e692007-12-29 00:20:38 -0600254 * linkgit:git-pull[1] to merge from your trusted lieutenants.
Junio C Hamanodb9536c2005-12-09 23:07:29 -0800255
Dan McGee5162e692007-12-29 00:20:38 -0600256 * linkgit:git-format-patch[1] to prepare and send suggested
Junio C Hamanodb9536c2005-12-09 23:07:29 -0800257 alternative to contributors.
258
Dan McGee5162e692007-12-29 00:20:38 -0600259 * linkgit:git-revert[1] to undo botched commits.
Junio C Hamanodb9536c2005-12-09 23:07:29 -0800260
Dan McGee5162e692007-12-29 00:20:38 -0600261 * linkgit:git-push[1] to publish the bleeding edge.
Junio C Hamanodb9536c2005-12-09 23:07:29 -0800262
263
Junio C Hamano180c4742005-12-12 18:29:53 -0800264Examples
265~~~~~~~~
266
Philip Oakley992cb202014-10-10 22:25:35 +0100267A typical integrator's Git day.::
Junio C Hamano1e2ccd32005-12-12 23:24:06 -0800268+
Junio C Hamano180c4742005-12-12 18:29:53 -0800269------------
270$ git status <1>
Philip Oakley992cb202014-10-10 22:25:35 +0100271$ git branch --no-merged master <2>
Junio C Hamano180c4742005-12-12 18:29:53 -0800272$ mailx <3>
273& s 2 3 4 5 ./+to-apply
274& s 7 8 ./+hold-linus
275& q
Nguyễn Thái Ngọc Duy328c6cb2019-03-29 17:39:19 +0700276$ git switch -c topic/one master
Philip Oakley992cb202014-10-10 22:25:35 +0100277$ git am -3 -i -s ./+to-apply <4>
Junio C Hamano180c4742005-12-12 18:29:53 -0800278$ compile/test
Nguyễn Thái Ngọc Duy328c6cb2019-03-29 17:39:19 +0700279$ git switch -c hold/linus && git am -3 -i -s ./+hold-linus <5>
280$ git switch topic/one && git rebase master <6>
281$ git switch -C pu next <7>
Junio C Hamano268b8272006-12-26 22:42:33 -0800282$ git merge topic/one topic/two && git merge hold/linus <8>
Nguyễn Thái Ngọc Duy328c6cb2019-03-29 17:39:19 +0700283$ git switch maint
Junio C Hamano01f49e32005-12-14 00:42:45 -0800284$ git cherry-pick master~4 <9>
Junio C Hamano180c4742005-12-12 18:29:53 -0800285$ compile/test
Sergei Organovd336fc02007-11-02 20:12:57 +0300286$ git tag -s -m "GIT 0.99.9x" v0.99.9x <10>
Philip Oakley992cb202014-10-10 22:25:35 +0100287$ git fetch ko && for branch in master maint next pu <11>
288 do
289 git show-branch ko/$branch $branch <12>
290 done
291$ git push --follow-tags ko <13>
Sean Estabrooks48aeecd2006-04-28 09:15:05 -0400292------------
293+
Philip Oakley992cb202014-10-10 22:25:35 +0100294<1> see what you were in the middle of doing, if anything.
295<2> see which branches haven't been merged into `master` yet.
296Likewise for any other integration branches e.g. `maint`, `next`
297and `pu` (potential updates).
Junio C Hamano180c4742005-12-12 18:29:53 -0800298<3> read mails, save ones that are applicable, and save others
Philip Oakley992cb202014-10-10 22:25:35 +0100299that are not quite ready (other mail readers are available).
300<4> apply them, interactively, with your sign-offs.
301<5> create topic branch as needed and apply, again with sign-offs.
Junio C Hamano1e2ccd32005-12-12 23:24:06 -0800302<6> rebase internal topic branch that has not been merged to the
Justin Lebara58088a2014-03-31 15:11:44 -0700303master or exposed as a part of a stable branch.
Junio C Hamano268b8272006-12-26 22:42:33 -0800304<7> restart `pu` every time from the next.
Junio C Hamano1e2ccd32005-12-12 23:24:06 -0800305<8> and bundle topic branches still cooking.
Junio C Hamano01f49e32005-12-14 00:42:45 -0800306<9> backport a critical fix.
307<10> create a signed tag.
Philip Oakley992cb202014-10-10 22:25:35 +0100308<11> make sure master was not accidentally rewound beyond that
Johannes Schindelin95749012017-01-02 17:04:05 +0100309already pushed out.
310<12> In the output from `git show-branch`, `master` should have
311everything `ko/master` has, and `next` should have
312everything `ko/next` has, etc.
313<13> push out the bleeding edge, together with new tags that point
314into the pushed history.
315
316In this example, the `ko` shorthand points at the Git maintainer's
Philip Oakley992cb202014-10-10 22:25:35 +0100317repository at kernel.org, and looks like this:
Johannes Schindelin95749012017-01-02 17:04:05 +0100318
Horst H. von Brand53bcf782006-06-04 22:10:33 -0400319------------
Philip Oakley992cb202014-10-10 22:25:35 +0100320(in .git/config)
321[remote "ko"]
322 url = kernel.org:/pub/scm/git/git.git
323 fetch = refs/heads/*:refs/remotes/ko/*
324 push = refs/heads/master
325 push = refs/heads/next
326 push = +refs/heads/pu
327 push = refs/heads/maint
Horst H. von Brand53bcf782006-06-04 22:10:33 -0400328------------
Junio C Hamano180c4742005-12-12 18:29:53 -0800329
330
Philip Oakley992cb202014-10-10 22:25:35 +0100331Repository Administration[[ADMINISTRATION]]
332-------------------------------------------
Junio C Hamanodb9536c2005-12-09 23:07:29 -0800333
334A repository administrator uses the following tools to set up
335and maintain access to the repository by developers.
336
Dan McGee5162e692007-12-29 00:20:38 -0600337 * linkgit:git-daemon[1] to allow anonymous download from
Junio C Hamanodb9536c2005-12-09 23:07:29 -0800338 repository.
339
Dan McGee5162e692007-12-29 00:20:38 -0600340 * linkgit:git-shell[1] can be used as a 'restricted login shell'
Junio C Hamanodb9536c2005-12-09 23:07:29 -0800341 for shared central repository users.
342
Philip Oakley992cb202014-10-10 22:25:35 +0100343 * linkgit:git-http-backend[1] provides a server side implementation
344 of Git-over-HTTP ("Smart http") allowing both fetch and push services.
345
346 * linkgit:gitweb[1] provides a web front-end to Git repositories,
347 which can be set-up using the linkgit:git-instaweb[1] script.
348
Sebastian Schuberthd5ff3b42013-09-06 22:03:22 +0200349link:howto/update-hook-example.html[update hook howto] has a good
Junio C Hamanod8081112005-12-18 12:11:27 -0800350example of managing a shared central repository.
Junio C Hamanodb9536c2005-12-09 23:07:29 -0800351
Philip Oakley992cb202014-10-10 22:25:35 +0100352In addition there are a number of other widely deployed hosting, browsing
353and reviewing solutions such as:
354
355 * gitolite, gerrit code review, cgit and others.
Junio C Hamano1e2ccd32005-12-12 23:24:06 -0800356
357Examples
358~~~~~~~~
Christian Couderf8a5da62006-10-27 07:00:57 +0200359We assume the following in /etc/services::
360+
361------------
362$ grep 9418 /etc/services
363git 9418/tcp # Git Version Control System
364------------
365
Junio C Hamano01f49e32005-12-14 00:42:45 -0800366Run git-daemon to serve /pub/scm from inetd.::
Junio C Hamano1e2ccd32005-12-12 23:24:06 -0800367+
368------------
Horst von Brand7872b182006-05-29 17:11:28 -0400369$ grep git /etc/inetd.conf
Junio C Hamano01f49e32005-12-14 00:42:45 -0800370git stream tcp nowait nobody \
Christian Couderd9c04ba2006-10-26 06:33:07 +0200371 /usr/bin/git-daemon git-daemon --inetd --export-all /pub/scm
Junio C Hamano1e2ccd32005-12-12 23:24:06 -0800372------------
Junio C Hamano01f49e32005-12-14 00:42:45 -0800373+
374The actual configuration line should be on one line.
Junio C Hamano1e2ccd32005-12-12 23:24:06 -0800375
Horst H. von Brandc51901d2006-06-04 19:53:45 -0400376Run git-daemon to serve /pub/scm from xinetd.::
377+
378------------
379$ cat /etc/xinetd.d/git-daemon
380# default: off
Thomas Ackermann2de9b712013-01-21 20:17:53 +0100381# description: The Git server offers access to Git repositories
Horst H. von Brandc51901d2006-06-04 19:53:45 -0400382service git
383{
Philip Oakley673151a2014-10-10 22:25:37 +0100384 disable = no
385 type = UNLISTED
386 port = 9418
387 socket_type = stream
388 wait = no
389 user = nobody
390 server = /usr/bin/git-daemon
391 server_args = --inetd --export-all --base-path=/pub/scm
392 log_on_failure += USERID
Horst H. von Brandc51901d2006-06-04 19:53:45 -0400393}
394------------
395+
396Check your xinetd(8) documentation and setup, this is from a Fedora system.
397Others might be different.
398
Philip Oakley992cb202014-10-10 22:25:35 +0100399Give push/pull only access to developers using git-over-ssh.::
400
401e.g. those using:
402`$ git push/pull ssh://host.xz/pub/scm/project`
Junio C Hamano1e2ccd32005-12-12 23:24:06 -0800403+
404------------
Junio C Hamano01f49e32005-12-14 00:42:45 -0800405$ grep git /etc/passwd <1>
Junio C Hamano1e2ccd32005-12-12 23:24:06 -0800406alice:x:1000:1000::/home/alice:/usr/bin/git-shell
407bob:x:1001:1001::/home/bob:/usr/bin/git-shell
408cindy:x:1002:1002::/home/cindy:/usr/bin/git-shell
409david:x:1003:1003::/home/david:/usr/bin/git-shell
Junio C Hamano01f49e32005-12-14 00:42:45 -0800410$ grep git /etc/shells <2>
411/usr/bin/git-shell
Sean Estabrooks48aeecd2006-04-28 09:15:05 -0400412------------
413+
Junio C Hamano01f49e32005-12-14 00:42:45 -0800414<1> log-in shell is set to /usr/bin/git-shell, which does not
Philip Oakley992cb202014-10-10 22:25:35 +0100415allow anything but `git push` and `git pull`. The users require
416ssh access to the machine.
Junio C Hamano01f49e32005-12-14 00:42:45 -0800417<2> in many distributions /etc/shells needs to list what is used
418as the login shell.
Junio C Hamano01f49e32005-12-14 00:42:45 -0800419
420CVS-style shared repository.::
421+
422------------
423$ grep git /etc/group <1>
424git:x:9418:alice,bob,cindy,david
425$ cd /home/devo.git
426$ ls -l <2>
427 lrwxrwxrwx 1 david git 17 Dec 4 22:40 HEAD -> refs/heads/master
428 drwxrwsr-x 2 david git 4096 Dec 4 22:40 branches
429 -rw-rw-r-- 1 david git 84 Dec 4 22:40 config
430 -rw-rw-r-- 1 david git 58 Dec 4 22:40 description
431 drwxrwsr-x 2 david git 4096 Dec 4 22:40 hooks
432 -rw-rw-r-- 1 david git 37504 Dec 4 22:40 index
433 drwxrwsr-x 2 david git 4096 Dec 4 22:40 info
434 drwxrwsr-x 4 david git 4096 Dec 4 22:40 objects
435 drwxrwsr-x 4 david git 4096 Nov 7 14:58 refs
436 drwxrwsr-x 2 david git 4096 Dec 4 22:40 remotes
437$ ls -l hooks/update <3>
438 -r-xr-xr-x 1 david git 3536 Dec 4 22:40 update
439$ cat info/allowed-users <4>
440refs/heads/master alice\|cindy
441refs/heads/doc-update bob
442refs/tags/v[0-9]* david
Sean Estabrooks48aeecd2006-04-28 09:15:05 -0400443------------
444+
Junio C Hamano01f49e32005-12-14 00:42:45 -0800445<1> place the developers into the same git group.
446<2> and make the shared repository writable by the group.
447<3> use update-hook example by Carl from Documentation/howto/
448for branch policy control.
449<4> alice and cindy can push into master, only bob can push into doc-update.
450david is the release manager and is the only person who can
451create and push version tags.
Junio C Hamano80248b22005-12-17 11:39:39 -0800452
Philip Oakley992cb202014-10-10 22:25:35 +0100453GIT
454---
455Part of the linkgit:git[1] suite