Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 1 | giteveryday(7) |
Junio C Hamano | f3f38c7 | 2015-10-22 10:14:44 -0700 | [diff] [blame] | 2 | ============== |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 3 | |
| 4 | NAME |
| 5 | ---- |
| 6 | giteveryday - A useful minimum set of commands for Everyday Git |
| 7 | |
| 8 | SYNOPSIS |
| 9 | -------- |
| 10 | |
Thomas Ackermann | 48a8c26 | 2013-01-21 20:16:20 +0100 | [diff] [blame] | 11 | Everyday Git With 20 Commands Or So |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 12 | |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 13 | DESCRIPTION |
| 14 | ----------- |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 15 | |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 16 | Git users can broadly be grouped into four categories for the purposes of |
| 17 | describing here a small set of useful command for everyday Git. |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 18 | |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 19 | * <<STANDALONE,Individual Developer (Standalone)>> commands are essential |
| 20 | for anybody who makes a commit, even for somebody who works alone. |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 21 | |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 22 | * 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 Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 31 | |
| 32 | |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 33 | Individual Developer (Standalone)[[STANDALONE]] |
| 34 | ----------------------------------------------- |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 35 | |
| 36 | A standalone individual developer does not exchange patches with |
Horst von Brand | 7872b18 | 2006-05-29 17:11:28 -0400 | [diff] [blame] | 37 | other people, and works alone in a single repository, using the |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 38 | following commands. |
| 39 | |
Anders Kaseorg | bce02c1 | 2009-10-21 16:02:48 -0400 | [diff] [blame] | 40 | * linkgit:git-init[1] to create a new repository. |
| 41 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 42 | * linkgit:git-log[1] to see what happened. |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 43 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 44 | * linkgit:git-checkout[1] and linkgit:git-branch[1] to switch |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 45 | branches. |
| 46 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 47 | * linkgit:git-add[1] to manage the index file. |
Junio C Hamano | 44db136 | 2005-12-12 16:20:21 -0800 | [diff] [blame] | 48 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 49 | * linkgit:git-diff[1] and linkgit:git-status[1] to see what |
Junio C Hamano | 44db136 | 2005-12-12 16:20:21 -0800 | [diff] [blame] | 50 | you are in the middle of doing. |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 51 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 52 | * linkgit:git-commit[1] to advance the current branch. |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 53 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 54 | * linkgit:git-reset[1] and linkgit:git-checkout[1] (with |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 55 | pathname parameters) to undo changes. |
| 56 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 57 | * linkgit:git-merge[1] to merge between local branches. |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 58 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 59 | * linkgit:git-rebase[1] to maintain topic branches. |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 60 | |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 61 | * linkgit:git-tag[1] to mark a known point. |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 62 | |
Junio C Hamano | 44db136 | 2005-12-12 16:20:21 -0800 | [diff] [blame] | 63 | Examples |
| 64 | ~~~~~~~~ |
| 65 | |
Junio C Hamano | 268b827 | 2006-12-26 22:42:33 -0800 | [diff] [blame] | 66 | Use a tarball as a starting point for a new repository.:: |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 67 | + |
Junio C Hamano | 44db136 | 2005-12-12 16:20:21 -0800 | [diff] [blame] | 68 | ------------ |
| 69 | $ tar zxf frotz.tar.gz |
| 70 | $ cd frotz |
David Aguilar | 3e5970a | 2009-03-22 02:15:13 -0700 | [diff] [blame] | 71 | $ git init |
Junio C Hamano | 180c474 | 2005-12-12 18:29:53 -0800 | [diff] [blame] | 72 | $ git add . <1> |
Sergei Organov | d336fc0 | 2007-11-02 20:12:57 +0300 | [diff] [blame] | 73 | $ git commit -m "import of frotz source tree." |
Junio C Hamano | 180c474 | 2005-12-12 18:29:53 -0800 | [diff] [blame] | 74 | $ git tag v2.43 <2> |
Sean Estabrooks | 48aeecd | 2006-04-28 09:15:05 -0400 | [diff] [blame] | 75 | ------------ |
| 76 | + |
Junio C Hamano | 180c474 | 2005-12-12 18:29:53 -0800 | [diff] [blame] | 77 | <1> add everything under the current directory. |
| 78 | <2> make a lightweight, unannotated tag. |
Junio C Hamano | 44db136 | 2005-12-12 16:20:21 -0800 | [diff] [blame] | 79 | |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 80 | Create a topic branch and develop.:: |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 81 | + |
Junio C Hamano | 44db136 | 2005-12-12 16:20:21 -0800 | [diff] [blame] | 82 | ------------ |
Junio C Hamano | 180c474 | 2005-12-12 18:29:53 -0800 | [diff] [blame] | 83 | $ git checkout -b alsa-audio <1> |
Junio C Hamano | 44db136 | 2005-12-12 16:20:21 -0800 | [diff] [blame] | 84 | $ edit/compile/test |
Junio C Hamano | 180c474 | 2005-12-12 18:29:53 -0800 | [diff] [blame] | 85 | $ git checkout -- curses/ux_audio_oss.c <2> |
| 86 | $ git add curses/ux_audio_alsa.c <3> |
Junio C Hamano | 44db136 | 2005-12-12 16:20:21 -0800 | [diff] [blame] | 87 | $ edit/compile/test |
Junio C Hamano | 268b827 | 2006-12-26 22:42:33 -0800 | [diff] [blame] | 88 | $ git diff HEAD <4> |
Junio C Hamano | 180c474 | 2005-12-12 18:29:53 -0800 | [diff] [blame] | 89 | $ git commit -a -s <5> |
| 90 | $ edit/compile/test |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 91 | $ git diff HEAD^ <6> |
| 92 | $ git commit -a --amend <7> |
| 93 | $ git checkout master <8> |
| 94 | $ git merge alsa-audio <9> |
| 95 | $ git log --since='3 days ago' <10> |
| 96 | $ git log v2.43.. curses/ <11> |
Sean Estabrooks | 48aeecd | 2006-04-28 09:15:05 -0400 | [diff] [blame] | 97 | ------------ |
| 98 | + |
Junio C Hamano | 180c474 | 2005-12-12 18:29:53 -0800 | [diff] [blame] | 99 | <1> create a new topic branch. |
Junio C Hamano | 268b827 | 2006-12-26 22:42:33 -0800 | [diff] [blame] | 100 | <2> revert your botched changes in `curses/ux_audio_oss.c`. |
Thomas Ackermann | 2de9b71 | 2013-01-21 20:17:53 +0100 | [diff] [blame] | 101 | <3> you need to tell Git if you added a new file; removal and |
Junio C Hamano | 268b827 | 2006-12-26 22:42:33 -0800 | [diff] [blame] | 102 | modification will be caught if you do `git commit -a` later. |
Junio C Hamano | 180c474 | 2005-12-12 18:29:53 -0800 | [diff] [blame] | 103 | <4> to see what changes you are committing. |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 104 | <5> commit everything, as you have tested, with your sign-off. |
| 105 | <6> look at all your changes including the previous commit. |
| 106 | <7> amend the previous commit, adding all your new changes, |
| 107 | using your original message. |
| 108 | <8> switch to the master branch. |
| 109 | <9> merge a topic branch into your master branch. |
| 110 | <10> review commit logs; other forms to limit output can be |
| 111 | combined and include `-10` (to show up to 10 commits), |
Jeff King | 6cf378f | 2012-04-26 04:51:57 -0400 | [diff] [blame] | 112 | `--until=2005-12-10`, etc. |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 113 | <11> view only the changes that touch what's in `curses/` |
Junio C Hamano | 268b827 | 2006-12-26 22:42:33 -0800 | [diff] [blame] | 114 | directory, since `v2.43` tag. |
Junio C Hamano | 44db136 | 2005-12-12 16:20:21 -0800 | [diff] [blame] | 115 | |
| 116 | |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 117 | Individual Developer (Participant)[[PARTICIPANT]] |
| 118 | ------------------------------------------------- |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 119 | |
| 120 | A developer working as a participant in a group project needs to |
| 121 | learn how to communicate with others, and uses these commands in |
| 122 | addition to the ones needed by a standalone developer. |
| 123 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 124 | * linkgit:git-clone[1] from the upstream to prime your local |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 125 | repository. |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 126 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 127 | * linkgit:git-pull[1] and linkgit:git-fetch[1] from "origin" |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 128 | to keep up-to-date with the upstream. |
| 129 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 130 | * linkgit:git-push[1] to shared repository, if you adopt CVS |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 131 | style shared repository workflow. |
| 132 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 133 | * linkgit:git-format-patch[1] to prepare e-mail submission, if |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 134 | you adopt Linux kernel-style public forum workflow. |
| 135 | |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 136 | * linkgit:git-send-email[1] to send your e-mail submission without |
| 137 | corruption by your MUA. |
| 138 | |
| 139 | * linkgit:git-request-pull[1] to create a summary of changes |
| 140 | for your upstream to pull. |
| 141 | |
| 142 | |
Junio C Hamano | 44db136 | 2005-12-12 16:20:21 -0800 | [diff] [blame] | 143 | Examples |
| 144 | ~~~~~~~~ |
| 145 | |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 146 | Clone the upstream and work on it. Feed changes to upstream.:: |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 147 | + |
Junio C Hamano | 44db136 | 2005-12-12 16:20:21 -0800 | [diff] [blame] | 148 | ------------ |
| 149 | $ git clone git://git.kernel.org/pub/scm/.../torvalds/linux-2.6 my2.6 |
| 150 | $ cd my2.6 |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 151 | $ git checkout -b mine master <1> |
| 152 | $ edit/compile/test; git commit -a -s <2> |
| 153 | $ git format-patch master <3> |
| 154 | $ git send-email --to="person <email@example.com>" 00*.patch <4> |
| 155 | $ git checkout master <5> |
| 156 | $ git pull <6> |
| 157 | $ git log -p ORIG_HEAD.. arch/i386 include/asm-i386 <7> |
| 158 | $ git ls-remote --heads http://git.kernel.org/.../jgarzik/libata-dev.git <8> |
| 159 | $ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <9> |
| 160 | $ git reset --hard ORIG_HEAD <10> |
| 161 | $ git gc <11> |
Sean Estabrooks | 48aeecd | 2006-04-28 09:15:05 -0400 | [diff] [blame] | 162 | ------------ |
| 163 | + |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 164 | <1> checkout a new branch `mine` from master. |
| 165 | <2> repeat as needed. |
| 166 | <3> extract patches from your branch, relative to master, |
| 167 | <4> and email them. |
| 168 | <5> return to `master`, ready to see what's new |
| 169 | <6> `git pull` fetches from `origin` by default and merges into the |
Junio C Hamano | d808111 | 2005-12-18 12:11:27 -0800 | [diff] [blame] | 170 | current branch. |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 171 | <7> immediately after pulling, look at the changes done upstream |
Junio C Hamano | d808111 | 2005-12-18 12:11:27 -0800 | [diff] [blame] | 172 | since last time we checked, only in the |
Junio C Hamano | 180c474 | 2005-12-12 18:29:53 -0800 | [diff] [blame] | 173 | area we are interested in. |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 174 | <8> check the branch names in an external repository (if not known). |
| 175 | <9> fetch from a specific branch `ALL` from a specific repository |
| 176 | and merge it. |
| 177 | <10> revert the pull. |
| 178 | <11> garbage collect leftover objects from reverted pull. |
Junio C Hamano | 44db136 | 2005-12-12 16:20:21 -0800 | [diff] [blame] | 179 | |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 180 | |
| 181 | Push into another repository.:: |
| 182 | + |
| 183 | ------------ |
Junio C Hamano | 268b827 | 2006-12-26 22:42:33 -0800 | [diff] [blame] | 184 | satellite$ git clone mothership:frotz frotz <1> |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 185 | satellite$ cd frotz |
Tom Prince | e0d10e1 | 2007-01-28 16:16:53 -0800 | [diff] [blame] | 186 | satellite$ git config --get-regexp '^(remote|branch)\.' <2> |
Junio C Hamano | 268b827 | 2006-12-26 22:42:33 -0800 | [diff] [blame] | 187 | remote.origin.url mothership:frotz |
| 188 | remote.origin.fetch refs/heads/*:refs/remotes/origin/* |
| 189 | branch.master.remote origin |
| 190 | branch.master.merge refs/heads/master |
Tom Prince | e0d10e1 | 2007-01-28 16:16:53 -0800 | [diff] [blame] | 191 | satellite$ git config remote.origin.push \ |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 192 | +refs/heads/*:refs/remotes/satellite/* <3> |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 193 | satellite$ edit/compile/test/commit |
| 194 | satellite$ git push origin <4> |
| 195 | |
| 196 | mothership$ cd frotz |
| 197 | mothership$ git checkout master |
Junio C Hamano | 268b827 | 2006-12-26 22:42:33 -0800 | [diff] [blame] | 198 | mothership$ git merge satellite/master <5> |
Sean Estabrooks | 48aeecd | 2006-04-28 09:15:05 -0400 | [diff] [blame] | 199 | ------------ |
| 200 | + |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 201 | <1> mothership machine has a frotz repository under your home |
| 202 | directory; clone from it to start a repository on the satellite |
| 203 | machine. |
Junio C Hamano | 268b827 | 2006-12-26 22:42:33 -0800 | [diff] [blame] | 204 | <2> clone sets these configuration variables by default. |
| 205 | It arranges `git pull` to fetch and store the branches of mothership |
Matthieu Moy | bc6dafc | 2010-11-02 16:31:22 +0100 | [diff] [blame] | 206 | machine to local `remotes/origin/*` remote-tracking branches. |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 207 | <3> arrange `git push` to push all local branches to |
| 208 | their corresponding branch of the mothership machine. |
| 209 | <4> push will stash all our work away on `remotes/satellite/*` |
| 210 | remote-tracking branches on the mothership machine. You could use this |
| 211 | as a back-up method. Likewise, you can pretend that mothership |
| 212 | "fetched" from you (useful when access is one sided). |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 213 | <5> on mothership machine, merge the work done on the satellite |
| 214 | machine into the master branch. |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 215 | |
| 216 | Branch off of a specific tag.:: |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 217 | + |
Junio C Hamano | 44db136 | 2005-12-12 16:20:21 -0800 | [diff] [blame] | 218 | ------------ |
| 219 | $ git checkout -b private2.6.14 v2.6.14 <1> |
| 220 | $ edit/compile/test; git commit -a |
| 221 | $ git checkout master |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 222 | $ git cherry-pick v2.6.14..private2.6.14 <2> |
Sean Estabrooks | 48aeecd | 2006-04-28 09:15:05 -0400 | [diff] [blame] | 223 | ------------ |
| 224 | + |
Junio C Hamano | 44db136 | 2005-12-12 16:20:21 -0800 | [diff] [blame] | 225 | <1> create a private branch based on a well known (but somewhat behind) |
| 226 | tag. |
Junio C Hamano | 268b827 | 2006-12-26 22:42:33 -0800 | [diff] [blame] | 227 | <2> forward port all changes in `private2.6.14` branch to `master` branch |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 228 | without a formal "merging". Or longhand + |
| 229 | `git format-patch -k -m --stdout v2.6.14..private2.6.14 | |
| 230 | git am -3 -k` |
Junio C Hamano | 44db136 | 2005-12-12 16:20:21 -0800 | [diff] [blame] | 231 | |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 232 | An alternate participant submission mechanism is using the |
| 233 | `git request-pull` or pull-request mechanisms (e.g as used on |
| 234 | GitHub (www.github.com) to notify your upstream of your |
| 235 | contribution. |
Junio C Hamano | 44db136 | 2005-12-12 16:20:21 -0800 | [diff] [blame] | 236 | |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 237 | Integrator[[INTEGRATOR]] |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 238 | ------------------------ |
| 239 | |
| 240 | A fairly central person acting as the integrator in a group |
| 241 | project receives changes made by others, reviews and integrates |
| 242 | them and publishes the result for others to use, using these |
| 243 | commands in addition to the ones needed by participants. |
| 244 | |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 245 | This section can also be used by those who respond to `git |
| 246 | request-pull` or pull-request on GitHub (www.github.com) to |
| 247 | integrate the work of others into their history. An sub-area |
| 248 | lieutenant for a repository will act both as a participant and |
| 249 | as an integrator. |
| 250 | |
| 251 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 252 | * linkgit:git-am[1] to apply patches e-mailed in from your |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 253 | contributors. |
| 254 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 255 | * linkgit:git-pull[1] to merge from your trusted lieutenants. |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 256 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 257 | * linkgit:git-format-patch[1] to prepare and send suggested |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 258 | alternative to contributors. |
| 259 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 260 | * linkgit:git-revert[1] to undo botched commits. |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 261 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 262 | * linkgit:git-push[1] to publish the bleeding edge. |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 263 | |
| 264 | |
Junio C Hamano | 180c474 | 2005-12-12 18:29:53 -0800 | [diff] [blame] | 265 | Examples |
| 266 | ~~~~~~~~ |
| 267 | |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 268 | A typical integrator's Git day.:: |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 269 | + |
Junio C Hamano | 180c474 | 2005-12-12 18:29:53 -0800 | [diff] [blame] | 270 | ------------ |
| 271 | $ git status <1> |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 272 | $ git branch --no-merged master <2> |
Junio C Hamano | 180c474 | 2005-12-12 18:29:53 -0800 | [diff] [blame] | 273 | $ mailx <3> |
| 274 | & s 2 3 4 5 ./+to-apply |
| 275 | & s 7 8 ./+hold-linus |
| 276 | & q |
Junio C Hamano | 268b827 | 2006-12-26 22:42:33 -0800 | [diff] [blame] | 277 | $ git checkout -b topic/one master |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 278 | $ git am -3 -i -s ./+to-apply <4> |
Junio C Hamano | 180c474 | 2005-12-12 18:29:53 -0800 | [diff] [blame] | 279 | $ compile/test |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 280 | $ git checkout -b hold/linus && git am -3 -i -s ./+hold-linus <5> |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 281 | $ git checkout topic/one && git rebase master <6> |
Junio C Hamano | 268b827 | 2006-12-26 22:42:33 -0800 | [diff] [blame] | 282 | $ git checkout pu && git reset --hard next <7> |
| 283 | $ git merge topic/one topic/two && git merge hold/linus <8> |
Junio C Hamano | 180c474 | 2005-12-12 18:29:53 -0800 | [diff] [blame] | 284 | $ git checkout maint |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 285 | $ git cherry-pick master~4 <9> |
Junio C Hamano | 180c474 | 2005-12-12 18:29:53 -0800 | [diff] [blame] | 286 | $ compile/test |
Sergei Organov | d336fc0 | 2007-11-02 20:12:57 +0300 | [diff] [blame] | 287 | $ git tag -s -m "GIT 0.99.9x" v0.99.9x <10> |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 288 | $ git fetch ko && for branch in master maint next pu <11> |
| 289 | do |
| 290 | git show-branch ko/$branch $branch <12> |
| 291 | done |
| 292 | $ git push --follow-tags ko <13> |
Sean Estabrooks | 48aeecd | 2006-04-28 09:15:05 -0400 | [diff] [blame] | 293 | ------------ |
| 294 | + |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 295 | <1> see what you were in the middle of doing, if anything. |
| 296 | <2> see which branches haven't been merged into `master` yet. |
| 297 | Likewise for any other integration branches e.g. `maint`, `next` |
| 298 | and `pu` (potential updates). |
Junio C Hamano | 180c474 | 2005-12-12 18:29:53 -0800 | [diff] [blame] | 299 | <3> read mails, save ones that are applicable, and save others |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 300 | that are not quite ready (other mail readers are available). |
| 301 | <4> apply them, interactively, with your sign-offs. |
| 302 | <5> create topic branch as needed and apply, again with sign-offs. |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 303 | <6> rebase internal topic branch that has not been merged to the |
Justin Lebar | a58088a | 2014-03-31 15:11:44 -0700 | [diff] [blame] | 304 | master or exposed as a part of a stable branch. |
Junio C Hamano | 268b827 | 2006-12-26 22:42:33 -0800 | [diff] [blame] | 305 | <7> restart `pu` every time from the next. |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 306 | <8> and bundle topic branches still cooking. |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 307 | <9> backport a critical fix. |
| 308 | <10> create a signed tag. |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 309 | <11> make sure master was not accidentally rewound beyond that |
Johannes Schindelin | 9574901 | 2017-01-02 17:04:05 +0100 | [diff] [blame] | 310 | already pushed out. |
| 311 | <12> In the output from `git show-branch`, `master` should have |
| 312 | everything `ko/master` has, and `next` should have |
| 313 | everything `ko/next` has, etc. |
| 314 | <13> push out the bleeding edge, together with new tags that point |
| 315 | into the pushed history. |
| 316 | |
| 317 | In this example, the `ko` shorthand points at the Git maintainer's |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 318 | repository at kernel.org, and looks like this: |
Johannes Schindelin | 9574901 | 2017-01-02 17:04:05 +0100 | [diff] [blame] | 319 | |
Horst H. von Brand | 53bcf78 | 2006-06-04 22:10:33 -0400 | [diff] [blame] | 320 | ------------ |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 321 | (in .git/config) |
| 322 | [remote "ko"] |
| 323 | url = kernel.org:/pub/scm/git/git.git |
| 324 | fetch = refs/heads/*:refs/remotes/ko/* |
| 325 | push = refs/heads/master |
| 326 | push = refs/heads/next |
| 327 | push = +refs/heads/pu |
| 328 | push = refs/heads/maint |
Horst H. von Brand | 53bcf78 | 2006-06-04 22:10:33 -0400 | [diff] [blame] | 329 | ------------ |
Junio C Hamano | 180c474 | 2005-12-12 18:29:53 -0800 | [diff] [blame] | 330 | |
| 331 | |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 332 | Repository Administration[[ADMINISTRATION]] |
| 333 | ------------------------------------------- |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 334 | |
| 335 | A repository administrator uses the following tools to set up |
| 336 | and maintain access to the repository by developers. |
| 337 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 338 | * linkgit:git-daemon[1] to allow anonymous download from |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 339 | repository. |
| 340 | |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 341 | * linkgit:git-shell[1] can be used as a 'restricted login shell' |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 342 | for shared central repository users. |
| 343 | |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 344 | * linkgit:git-http-backend[1] provides a server side implementation |
| 345 | of Git-over-HTTP ("Smart http") allowing both fetch and push services. |
| 346 | |
| 347 | * linkgit:gitweb[1] provides a web front-end to Git repositories, |
| 348 | which can be set-up using the linkgit:git-instaweb[1] script. |
| 349 | |
Sebastian Schuberth | d5ff3b4 | 2013-09-06 22:03:22 +0200 | [diff] [blame] | 350 | link:howto/update-hook-example.html[update hook howto] has a good |
Junio C Hamano | d808111 | 2005-12-18 12:11:27 -0800 | [diff] [blame] | 351 | example of managing a shared central repository. |
Junio C Hamano | db9536c | 2005-12-09 23:07:29 -0800 | [diff] [blame] | 352 | |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 353 | In addition there are a number of other widely deployed hosting, browsing |
| 354 | and reviewing solutions such as: |
| 355 | |
| 356 | * gitolite, gerrit code review, cgit and others. |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 357 | |
| 358 | Examples |
| 359 | ~~~~~~~~ |
Christian Couder | f8a5da6 | 2006-10-27 07:00:57 +0200 | [diff] [blame] | 360 | We assume the following in /etc/services:: |
| 361 | + |
| 362 | ------------ |
| 363 | $ grep 9418 /etc/services |
| 364 | git 9418/tcp # Git Version Control System |
| 365 | ------------ |
| 366 | |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 367 | Run git-daemon to serve /pub/scm from inetd.:: |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 368 | + |
| 369 | ------------ |
Horst von Brand | 7872b18 | 2006-05-29 17:11:28 -0400 | [diff] [blame] | 370 | $ grep git /etc/inetd.conf |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 371 | git stream tcp nowait nobody \ |
Christian Couder | d9c04ba | 2006-10-26 06:33:07 +0200 | [diff] [blame] | 372 | /usr/bin/git-daemon git-daemon --inetd --export-all /pub/scm |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 373 | ------------ |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 374 | + |
| 375 | The actual configuration line should be on one line. |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 376 | |
Horst H. von Brand | c51901d | 2006-06-04 19:53:45 -0400 | [diff] [blame] | 377 | Run git-daemon to serve /pub/scm from xinetd.:: |
| 378 | + |
| 379 | ------------ |
| 380 | $ cat /etc/xinetd.d/git-daemon |
| 381 | # default: off |
Thomas Ackermann | 2de9b71 | 2013-01-21 20:17:53 +0100 | [diff] [blame] | 382 | # description: The Git server offers access to Git repositories |
Horst H. von Brand | c51901d | 2006-06-04 19:53:45 -0400 | [diff] [blame] | 383 | service git |
| 384 | { |
Philip Oakley | 673151a | 2014-10-10 22:25:37 +0100 | [diff] [blame] | 385 | disable = no |
| 386 | type = UNLISTED |
| 387 | port = 9418 |
| 388 | socket_type = stream |
| 389 | wait = no |
| 390 | user = nobody |
| 391 | server = /usr/bin/git-daemon |
| 392 | server_args = --inetd --export-all --base-path=/pub/scm |
| 393 | log_on_failure += USERID |
Horst H. von Brand | c51901d | 2006-06-04 19:53:45 -0400 | [diff] [blame] | 394 | } |
| 395 | ------------ |
| 396 | + |
| 397 | Check your xinetd(8) documentation and setup, this is from a Fedora system. |
| 398 | Others might be different. |
| 399 | |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 400 | Give push/pull only access to developers using git-over-ssh.:: |
| 401 | |
| 402 | e.g. those using: |
| 403 | `$ git push/pull ssh://host.xz/pub/scm/project` |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 404 | + |
| 405 | ------------ |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 406 | $ grep git /etc/passwd <1> |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 407 | alice:x:1000:1000::/home/alice:/usr/bin/git-shell |
| 408 | bob:x:1001:1001::/home/bob:/usr/bin/git-shell |
| 409 | cindy:x:1002:1002::/home/cindy:/usr/bin/git-shell |
| 410 | david:x:1003:1003::/home/david:/usr/bin/git-shell |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 411 | $ grep git /etc/shells <2> |
| 412 | /usr/bin/git-shell |
Sean Estabrooks | 48aeecd | 2006-04-28 09:15:05 -0400 | [diff] [blame] | 413 | ------------ |
| 414 | + |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 415 | <1> log-in shell is set to /usr/bin/git-shell, which does not |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 416 | allow anything but `git push` and `git pull`. The users require |
| 417 | ssh access to the machine. |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 418 | <2> in many distributions /etc/shells needs to list what is used |
| 419 | as the login shell. |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 420 | |
| 421 | CVS-style shared repository.:: |
| 422 | + |
| 423 | ------------ |
| 424 | $ grep git /etc/group <1> |
| 425 | git:x:9418:alice,bob,cindy,david |
| 426 | $ cd /home/devo.git |
| 427 | $ ls -l <2> |
| 428 | lrwxrwxrwx 1 david git 17 Dec 4 22:40 HEAD -> refs/heads/master |
| 429 | drwxrwsr-x 2 david git 4096 Dec 4 22:40 branches |
| 430 | -rw-rw-r-- 1 david git 84 Dec 4 22:40 config |
| 431 | -rw-rw-r-- 1 david git 58 Dec 4 22:40 description |
| 432 | drwxrwsr-x 2 david git 4096 Dec 4 22:40 hooks |
| 433 | -rw-rw-r-- 1 david git 37504 Dec 4 22:40 index |
| 434 | drwxrwsr-x 2 david git 4096 Dec 4 22:40 info |
| 435 | drwxrwsr-x 4 david git 4096 Dec 4 22:40 objects |
| 436 | drwxrwsr-x 4 david git 4096 Nov 7 14:58 refs |
| 437 | drwxrwsr-x 2 david git 4096 Dec 4 22:40 remotes |
| 438 | $ ls -l hooks/update <3> |
| 439 | -r-xr-xr-x 1 david git 3536 Dec 4 22:40 update |
| 440 | $ cat info/allowed-users <4> |
| 441 | refs/heads/master alice\|cindy |
| 442 | refs/heads/doc-update bob |
| 443 | refs/tags/v[0-9]* david |
Sean Estabrooks | 48aeecd | 2006-04-28 09:15:05 -0400 | [diff] [blame] | 444 | ------------ |
| 445 | + |
Junio C Hamano | 01f49e3 | 2005-12-14 00:42:45 -0800 | [diff] [blame] | 446 | <1> place the developers into the same git group. |
| 447 | <2> and make the shared repository writable by the group. |
| 448 | <3> use update-hook example by Carl from Documentation/howto/ |
| 449 | for branch policy control. |
| 450 | <4> alice and cindy can push into master, only bob can push into doc-update. |
| 451 | david is the release manager and is the only person who can |
| 452 | create and push version tags. |
Junio C Hamano | 80248b2 | 2005-12-17 11:39:39 -0800 | [diff] [blame] | 453 | |
Philip Oakley | 992cb20 | 2014-10-10 22:25:35 +0100 | [diff] [blame] | 454 | GIT |
| 455 | --- |
| 456 | Part of the linkgit:git[1] suite |