Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1 | Everyday GIT With 20 Commands Or So |
| 2 | =================================== |
| 3 | |
Junio C Hamano | ef8fbf9 | 2010-04-04 19:12:02 | [diff] [blame] | 4 | <<Individual Developer (Standalone)>> commands are essential for |
| 5 | anybody who makes a commit, even for somebody who works alone. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 6 | |
| 7 | If you work with other people, you will need commands listed in |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 8 | the <<Individual Developer (Participant)>> section as well. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 9 | |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 10 | People who play the <<Integrator>> role need to learn some more |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 11 | commands in addition to the above. |
| 12 | |
| 13 | <<Repository Administration>> commands are for system |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 14 | administrators who are responsible for the care and feeding |
| 15 | of git repositories. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 16 | |
| 17 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 18 | Individual Developer (Standalone)[[Individual Developer (Standalone)]] |
| 19 | ---------------------------------------------------------------------- |
| 20 | |
| 21 | A standalone individual developer does not exchange patches with |
Junio C Hamano | bb8fb05 | 2006-05-30 07:21:12 | [diff] [blame] | 22 | other people, and works alone in a single repository, using the |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 23 | following commands. |
| 24 | |
Junio C Hamano | ef8fbf9 | 2010-04-04 19:12:02 | [diff] [blame] | 25 | * linkgit:git-init[1] to create a new repository. |
| 26 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 27 | * linkgit:git-show-branch[1] to see where you are. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 28 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 29 | * linkgit:git-log[1] to see what happened. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 30 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 31 | * linkgit:git-checkout[1] and linkgit:git-branch[1] to switch |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 32 | branches. |
| 33 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 34 | * linkgit:git-add[1] to manage the index file. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 35 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 36 | * linkgit:git-diff[1] and linkgit:git-status[1] to see what |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 37 | you are in the middle of doing. |
| 38 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 39 | * linkgit:git-commit[1] to advance the current branch. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 40 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 41 | * linkgit:git-reset[1] and linkgit:git-checkout[1] (with |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 42 | pathname parameters) to undo changes. |
| 43 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 44 | * linkgit:git-merge[1] to merge between local branches. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 45 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 46 | * linkgit:git-rebase[1] to maintain topic branches. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 47 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 48 | * linkgit:git-tag[1] to mark known point. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 49 | |
| 50 | Examples |
| 51 | ~~~~~~~~ |
| 52 | |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 53 | Use a tarball as a starting point for a new repository.:: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 54 | + |
| 55 | ------------ |
| 56 | $ tar zxf frotz.tar.gz |
| 57 | $ cd frotz |
Junio C Hamano | 883263c | 2009-03-23 00:03:40 | [diff] [blame] | 58 | $ git init |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 59 | $ git add . <1> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 60 | $ git commit -m "import of frotz source tree." |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 61 | $ git tag v2.43 <2> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 62 | ------------ |
| 63 | + |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 64 | <1> add everything under the current directory. |
| 65 | <2> make a lightweight, unannotated tag. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 66 | |
| 67 | Create a topic branch and develop.:: |
| 68 | + |
| 69 | ------------ |
| 70 | $ git checkout -b alsa-audio <1> |
| 71 | $ edit/compile/test |
| 72 | $ git checkout -- curses/ux_audio_oss.c <2> |
| 73 | $ git add curses/ux_audio_alsa.c <3> |
| 74 | $ edit/compile/test |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 75 | $ git diff HEAD <4> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 76 | $ git commit -a -s <5> |
| 77 | $ edit/compile/test |
| 78 | $ git reset --soft HEAD^ <6> |
| 79 | $ edit/compile/test |
| 80 | $ git diff ORIG_HEAD <7> |
| 81 | $ git commit -a -c ORIG_HEAD <8> |
| 82 | $ git checkout master <9> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 83 | $ git merge alsa-audio <10> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 84 | $ git log --since='3 days ago' <11> |
| 85 | $ git log v2.43.. curses/ <12> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 86 | ------------ |
| 87 | + |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 88 | <1> create a new topic branch. |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 89 | <2> revert your botched changes in `curses/ux_audio_oss.c`. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 90 | <3> you need to tell git if you added a new file; removal and |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 91 | modification will be caught if you do `git commit -a` later. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 92 | <4> to see what changes you are committing. |
| 93 | <5> commit everything as you have tested, with your sign-off. |
| 94 | <6> take the last commit back, keeping what is in the working tree. |
| 95 | <7> look at the changes since the premature commit we took back. |
| 96 | <8> redo the commit undone in the previous step, using the message |
| 97 | you originally wrote. |
| 98 | <9> switch to the master branch. |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 99 | <10> merge a topic branch into your master branch. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 100 | <11> review commit logs; other forms to limit output can be |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 101 | combined and include `\--max-count=10` (show 10 commits), |
| 102 | `\--until=2005-12-10`, etc. |
| 103 | <12> view only the changes that touch what's in `curses/` |
| 104 | directory, since `v2.43` tag. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 105 | |
| 106 | |
| 107 | Individual Developer (Participant)[[Individual Developer (Participant)]] |
| 108 | ------------------------------------------------------------------------ |
| 109 | |
| 110 | A developer working as a participant in a group project needs to |
| 111 | learn how to communicate with others, and uses these commands in |
| 112 | addition to the ones needed by a standalone developer. |
| 113 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 114 | * linkgit:git-clone[1] from the upstream to prime your local |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 115 | repository. |
| 116 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 117 | * linkgit:git-pull[1] and linkgit:git-fetch[1] from "origin" |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 118 | to keep up-to-date with the upstream. |
| 119 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 120 | * linkgit:git-push[1] to shared repository, if you adopt CVS |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 121 | style shared repository workflow. |
| 122 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 123 | * linkgit:git-format-patch[1] to prepare e-mail submission, if |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 124 | you adopt Linux kernel-style public forum workflow. |
| 125 | |
| 126 | Examples |
| 127 | ~~~~~~~~ |
| 128 | |
| 129 | Clone the upstream and work on it. Feed changes to upstream.:: |
| 130 | + |
| 131 | ------------ |
| 132 | $ git clone git://git.kernel.org/pub/scm/.../torvalds/linux-2.6 my2.6 |
| 133 | $ cd my2.6 |
| 134 | $ edit/compile/test; git commit -a -s <1> |
| 135 | $ git format-patch origin <2> |
| 136 | $ git pull <3> |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 137 | $ git log -p ORIG_HEAD.. arch/i386 include/asm-i386 <4> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 138 | $ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <5> |
| 139 | $ git reset --hard ORIG_HEAD <6> |
Junio C Hamano | a9aee78 | 2008-04-23 16:09:20 | [diff] [blame] | 140 | $ git gc <7> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 141 | $ git fetch --tags <8> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 142 | ------------ |
| 143 | + |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 144 | <1> repeat as needed. |
| 145 | <2> extract patches from your branch for e-mail submission. |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 146 | <3> `git pull` fetches from `origin` by default and merges into the |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 147 | current branch. |
| 148 | <4> immediately after pulling, look at the changes done upstream |
| 149 | since last time we checked, only in the |
| 150 | area we are interested in. |
| 151 | <5> fetch from a specific branch from a specific repository and merge. |
| 152 | <6> revert the pull. |
| 153 | <7> garbage collect leftover objects from reverted pull. |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 154 | <8> from time to time, obtain official tags from the `origin` |
| 155 | and store them under `.git/refs/tags/`. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 156 | |
| 157 | |
| 158 | Push into another repository.:: |
| 159 | + |
| 160 | ------------ |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 161 | satellite$ git clone mothership:frotz frotz <1> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 162 | satellite$ cd frotz |
Junio C Hamano | 7ad22dc | 2007-01-29 02:55:48 | [diff] [blame] | 163 | satellite$ git config --get-regexp '^(remote|branch)\.' <2> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 164 | remote.origin.url mothership:frotz |
| 165 | remote.origin.fetch refs/heads/*:refs/remotes/origin/* |
| 166 | branch.master.remote origin |
| 167 | branch.master.merge refs/heads/master |
Junio C Hamano | 7ad22dc | 2007-01-29 02:55:48 | [diff] [blame] | 168 | satellite$ git config remote.origin.push \ |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 169 | master:refs/remotes/satellite/master <3> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 170 | satellite$ edit/compile/test/commit |
| 171 | satellite$ git push origin <4> |
| 172 | |
| 173 | mothership$ cd frotz |
| 174 | mothership$ git checkout master |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 175 | mothership$ git merge satellite/master <5> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 176 | ------------ |
| 177 | + |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 178 | <1> mothership machine has a frotz repository under your home |
| 179 | directory; clone from it to start a repository on the satellite |
| 180 | machine. |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 181 | <2> clone sets these configuration variables by default. |
| 182 | It arranges `git pull` to fetch and store the branches of mothership |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 183 | machine to local `remotes/origin/*` remote-tracking branches. |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 184 | <3> arrange `git push` to push local `master` branch to |
| 185 | `remotes/satellite/master` branch of the mothership machine. |
| 186 | <4> push will stash our work away on `remotes/satellite/master` |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 187 | remote-tracking branch on the mothership machine. You could use this |
| 188 | as a back-up method. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 189 | <5> on mothership machine, merge the work done on the satellite |
| 190 | machine into the master branch. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 191 | |
| 192 | Branch off of a specific tag.:: |
| 193 | + |
| 194 | ------------ |
| 195 | $ git checkout -b private2.6.14 v2.6.14 <1> |
| 196 | $ edit/compile/test; git commit -a |
| 197 | $ git checkout master |
| 198 | $ git format-patch -k -m --stdout v2.6.14..private2.6.14 | |
| 199 | git am -3 -k <2> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 200 | ------------ |
| 201 | + |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 202 | <1> create a private branch based on a well known (but somewhat behind) |
| 203 | tag. |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 204 | <2> forward port all changes in `private2.6.14` branch to `master` branch |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 205 | without a formal "merging". |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 206 | |
| 207 | |
| 208 | Integrator[[Integrator]] |
| 209 | ------------------------ |
| 210 | |
| 211 | A fairly central person acting as the integrator in a group |
| 212 | project receives changes made by others, reviews and integrates |
| 213 | them and publishes the result for others to use, using these |
| 214 | commands in addition to the ones needed by participants. |
| 215 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 216 | * linkgit:git-am[1] to apply patches e-mailed in from your |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 217 | contributors. |
| 218 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 219 | * linkgit:git-pull[1] to merge from your trusted lieutenants. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 220 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 221 | * linkgit:git-format-patch[1] to prepare and send suggested |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 222 | alternative to contributors. |
| 223 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 224 | * linkgit:git-revert[1] to undo botched commits. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 225 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 226 | * linkgit:git-push[1] to publish the bleeding edge. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 227 | |
| 228 | |
| 229 | Examples |
| 230 | ~~~~~~~~ |
| 231 | |
| 232 | My typical GIT day.:: |
| 233 | + |
| 234 | ------------ |
| 235 | $ git status <1> |
| 236 | $ git show-branch <2> |
| 237 | $ mailx <3> |
| 238 | & s 2 3 4 5 ./+to-apply |
| 239 | & s 7 8 ./+hold-linus |
| 240 | & q |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 241 | $ git checkout -b topic/one master |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 242 | $ git am -3 -i -s -u ./+to-apply <4> |
| 243 | $ compile/test |
| 244 | $ git checkout -b hold/linus && git am -3 -i -s -u ./+hold-linus <5> |
| 245 | $ git checkout topic/one && git rebase master <6> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 246 | $ git checkout pu && git reset --hard next <7> |
| 247 | $ git merge topic/one topic/two && git merge hold/linus <8> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 248 | $ git checkout maint |
| 249 | $ git cherry-pick master~4 <9> |
| 250 | $ compile/test |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 251 | $ git tag -s -m "GIT 0.99.9x" v0.99.9x <10> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 252 | $ git fetch ko && git show-branch master maint 'tags/ko-*' <11> |
| 253 | $ git push ko <12> |
| 254 | $ git push ko v0.99.9x <13> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 255 | ------------ |
| 256 | + |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 257 | <1> see what I was in the middle of doing, if any. |
| 258 | <2> see what topic branches I have and think about how ready |
| 259 | they are. |
| 260 | <3> read mails, save ones that are applicable, and save others |
| 261 | that are not quite ready. |
| 262 | <4> apply them, interactively, with my sign-offs. |
| 263 | <5> create topic branch as needed and apply, again with my |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 264 | sign-offs. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 265 | <6> rebase internal topic branch that has not been merged to the |
| 266 | master, nor exposed as a part of a stable branch. |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 267 | <7> restart `pu` every time from the next. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 268 | <8> and bundle topic branches still cooking. |
| 269 | <9> backport a critical fix. |
| 270 | <10> create a signed tag. |
| 271 | <11> make sure I did not accidentally rewind master beyond what I |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 272 | already pushed out. `ko` shorthand points at the repository I have |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 273 | at kernel.org, and looks like this: |
Junio C Hamano | 7da87bb | 2006-06-06 01:23:49 | [diff] [blame] | 274 | + |
| 275 | ------------ |
| 276 | $ cat .git/remotes/ko |
| 277 | URL: kernel.org:/pub/scm/git/git.git |
| 278 | Pull: master:refs/tags/ko-master |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 279 | Pull: next:refs/tags/ko-next |
Junio C Hamano | 7da87bb | 2006-06-06 01:23:49 | [diff] [blame] | 280 | Pull: maint:refs/tags/ko-maint |
| 281 | Push: master |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 282 | Push: next |
Junio C Hamano | 7da87bb | 2006-06-06 01:23:49 | [diff] [blame] | 283 | Push: +pu |
| 284 | Push: maint |
| 285 | ------------ |
| 286 | + |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 287 | In the output from `git show-branch`, `master` should have |
| 288 | everything `ko-master` has, and `next` should have |
| 289 | everything `ko-next` has. |
Junio C Hamano | 7da87bb | 2006-06-06 01:23:49 | [diff] [blame] | 290 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 291 | <12> push out the bleeding edge. |
| 292 | <13> push the tag out, too. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 293 | |
| 294 | |
| 295 | Repository Administration[[Repository Administration]] |
| 296 | ------------------------------------------------------ |
| 297 | |
| 298 | A repository administrator uses the following tools to set up |
| 299 | and maintain access to the repository by developers. |
| 300 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 301 | * linkgit:git-daemon[1] to allow anonymous download from |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 302 | repository. |
| 303 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 304 | * linkgit:git-shell[1] can be used as a 'restricted login shell' |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 305 | for shared central repository users. |
| 306 | |
| 307 | link:howto/update-hook-example.txt[update hook howto] has a good |
| 308 | example of managing a shared central repository. |
| 309 | |
| 310 | |
| 311 | Examples |
| 312 | ~~~~~~~~ |
Junio C Hamano | a053d54 | 2006-10-27 09:29:13 | [diff] [blame] | 313 | We assume the following in /etc/services:: |
| 314 | + |
| 315 | ------------ |
| 316 | $ grep 9418 /etc/services |
| 317 | git 9418/tcp # Git Version Control System |
| 318 | ------------ |
| 319 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 320 | Run git-daemon to serve /pub/scm from inetd.:: |
| 321 | + |
| 322 | ------------ |
Junio C Hamano | bb8fb05 | 2006-05-30 07:21:12 | [diff] [blame] | 323 | $ grep git /etc/inetd.conf |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 324 | git stream tcp nowait nobody \ |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 325 | /usr/bin/git-daemon git-daemon --inetd --export-all /pub/scm |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 326 | ------------ |
| 327 | + |
| 328 | The actual configuration line should be on one line. |
| 329 | |
Junio C Hamano | 7da87bb | 2006-06-06 01:23:49 | [diff] [blame] | 330 | Run git-daemon to serve /pub/scm from xinetd.:: |
| 331 | + |
| 332 | ------------ |
| 333 | $ cat /etc/xinetd.d/git-daemon |
| 334 | # default: off |
| 335 | # description: The git server offers access to git repositories |
| 336 | service git |
| 337 | { |
| 338 | disable = no |
| 339 | type = UNLISTED |
| 340 | port = 9418 |
| 341 | socket_type = stream |
| 342 | wait = no |
| 343 | user = nobody |
| 344 | server = /usr/bin/git-daemon |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 345 | server_args = --inetd --export-all --base-path=/pub/scm |
Junio C Hamano | 7da87bb | 2006-06-06 01:23:49 | [diff] [blame] | 346 | log_on_failure += USERID |
| 347 | } |
| 348 | ------------ |
| 349 | + |
| 350 | Check your xinetd(8) documentation and setup, this is from a Fedora system. |
| 351 | Others might be different. |
| 352 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 353 | Give push/pull only access to developers.:: |
| 354 | + |
| 355 | ------------ |
| 356 | $ grep git /etc/passwd <1> |
| 357 | alice:x:1000:1000::/home/alice:/usr/bin/git-shell |
| 358 | bob:x:1001:1001::/home/bob:/usr/bin/git-shell |
| 359 | cindy:x:1002:1002::/home/cindy:/usr/bin/git-shell |
| 360 | david:x:1003:1003::/home/david:/usr/bin/git-shell |
| 361 | $ grep git /etc/shells <2> |
| 362 | /usr/bin/git-shell |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 363 | ------------ |
| 364 | + |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 365 | <1> log-in shell is set to /usr/bin/git-shell, which does not |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 366 | allow anything but `git push` and `git pull`. The users should |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 367 | get an ssh access to the machine. |
| 368 | <2> in many distributions /etc/shells needs to list what is used |
| 369 | as the login shell. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 370 | |
| 371 | CVS-style shared repository.:: |
| 372 | + |
| 373 | ------------ |
| 374 | $ grep git /etc/group <1> |
| 375 | git:x:9418:alice,bob,cindy,david |
| 376 | $ cd /home/devo.git |
| 377 | $ ls -l <2> |
| 378 | lrwxrwxrwx 1 david git 17 Dec 4 22:40 HEAD -> refs/heads/master |
| 379 | drwxrwsr-x 2 david git 4096 Dec 4 22:40 branches |
| 380 | -rw-rw-r-- 1 david git 84 Dec 4 22:40 config |
| 381 | -rw-rw-r-- 1 david git 58 Dec 4 22:40 description |
| 382 | drwxrwsr-x 2 david git 4096 Dec 4 22:40 hooks |
| 383 | -rw-rw-r-- 1 david git 37504 Dec 4 22:40 index |
| 384 | drwxrwsr-x 2 david git 4096 Dec 4 22:40 info |
| 385 | drwxrwsr-x 4 david git 4096 Dec 4 22:40 objects |
| 386 | drwxrwsr-x 4 david git 4096 Nov 7 14:58 refs |
| 387 | drwxrwsr-x 2 david git 4096 Dec 4 22:40 remotes |
| 388 | $ ls -l hooks/update <3> |
| 389 | -r-xr-xr-x 1 david git 3536 Dec 4 22:40 update |
| 390 | $ cat info/allowed-users <4> |
| 391 | refs/heads/master alice\|cindy |
| 392 | refs/heads/doc-update bob |
| 393 | refs/tags/v[0-9]* david |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 394 | ------------ |
| 395 | + |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 396 | <1> place the developers into the same git group. |
| 397 | <2> and make the shared repository writable by the group. |
| 398 | <3> use update-hook example by Carl from Documentation/howto/ |
| 399 | for branch policy control. |
| 400 | <4> alice and cindy can push into master, only bob can push into doc-update. |
| 401 | david is the release manager and is the only person who can |
| 402 | create and push version tags. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 403 | |
| 404 | HTTP server to support dumb protocol transfer.:: |
| 405 | + |
| 406 | ------------ |
| 407 | dev$ git update-server-info <1> |
| 408 | dev$ ftp user@isp.example.com <2> |
| 409 | ftp> cp -r .git /home/user/myproject.git |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 410 | ------------ |
| 411 | + |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 412 | <1> make sure your info/refs and objects/info/packs are up-to-date |
| 413 | <2> upload to public HTTP server hosted by your ISP. |