Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1 | gittutorial(7) |
| 2 | ============== |
| 3 | |
| 4 | NAME |
| 5 | ---- |
| 6 | gittutorial - A tutorial introduction to git (for version 1.5.1 or newer) |
| 7 | |
| 8 | SYNOPSIS |
| 9 | -------- |
| 10 | git * |
| 11 | |
| 12 | DESCRIPTION |
| 13 | ----------- |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 14 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 15 | This tutorial explains how to import a new project into git, make |
| 16 | changes to it, and share changes with other developers. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 17 | |
Junio C Hamano | ed7f4f6 | 2007-05-20 09:09:09 | [diff] [blame] | 18 | If you are instead primarily interested in using git to fetch a project, |
| 19 | for example, to test the latest version, you may prefer to start with |
| 20 | the first two chapters of link:user-manual.html[The Git User's Manual]. |
| 21 | |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 22 | First, note that you can get documentation for a command such as |
| 23 | `git log --graph` with: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 24 | |
| 25 | ------------------------------------------------ |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 26 | $ man git-log |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 27 | ------------------------------------------------ |
| 28 | |
Junio C Hamano | f66ecee | 2008-11-17 18:25:43 | [diff] [blame] | 29 | or: |
| 30 | |
| 31 | ------------------------------------------------ |
| 32 | $ git help log |
| 33 | ------------------------------------------------ |
| 34 | |
| 35 | With the latter, you can use the manual viewer of your choice; see |
| 36 | linkgit:git-help[1] for more information. |
| 37 | |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 38 | It is a good idea to introduce yourself to git with your name and |
| 39 | public email address before doing any operation. The easiest |
| 40 | way to do so is: |
Junio C Hamano | 699660b | 2006-11-29 20:40:10 | [diff] [blame] | 41 | |
| 42 | ------------------------------------------------ |
Junio C Hamano | 7ad22dc | 2007-01-29 02:55:48 | [diff] [blame] | 43 | $ git config --global user.name "Your Name Comes Here" |
| 44 | $ git config --global user.email you@yourdomain.example.com |
Junio C Hamano | 699660b | 2006-11-29 20:40:10 | [diff] [blame] | 45 | ------------------------------------------------ |
| 46 | |
| 47 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 48 | Importing a new project |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 49 | ----------------------- |
| 50 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 51 | Assume you have a tarball project.tar.gz with your initial work. You |
| 52 | can place it under git revision control as follows. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 53 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 54 | ------------------------------------------------ |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 55 | $ tar xzf project.tar.gz |
| 56 | $ cd project |
Junio C Hamano | fc4d38c | 2007-01-08 06:53:32 | [diff] [blame] | 57 | $ git init |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 58 | ------------------------------------------------ |
| 59 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 60 | Git will reply |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 61 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 62 | ------------------------------------------------ |
Junio C Hamano | 7d23f5e | 2006-12-16 07:44:04 | [diff] [blame] | 63 | Initialized empty Git repository in .git/ |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 64 | ------------------------------------------------ |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 65 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 66 | You've now initialized the working directory--you may notice a new |
Junio C Hamano | ed7f4f6 | 2007-05-20 09:09:09 | [diff] [blame] | 67 | directory created, named ".git". |
| 68 | |
| 69 | Next, tell git to take a snapshot of the contents of all files under the |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 70 | current directory (note the '.'), with 'git add': |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 71 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 72 | ------------------------------------------------ |
| 73 | $ git add . |
| 74 | ------------------------------------------------ |
| 75 | |
Junio C Hamano | ed7f4f6 | 2007-05-20 09:09:09 | [diff] [blame] | 76 | This snapshot is now stored in a temporary staging area which git calls |
| 77 | the "index". You can permanently store the contents of the index in the |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 78 | repository with 'git commit': |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 79 | |
| 80 | ------------------------------------------------ |
Junio C Hamano | 699660b | 2006-11-29 20:40:10 | [diff] [blame] | 81 | $ git commit |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 82 | ------------------------------------------------ |
| 83 | |
Junio C Hamano | ed7f4f6 | 2007-05-20 09:09:09 | [diff] [blame] | 84 | This will prompt you for a commit message. You've now stored the first |
| 85 | version of your project in git. |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 86 | |
Junio C Hamano | 79770b6 | 2007-01-07 07:43:58 | [diff] [blame] | 87 | Making changes |
| 88 | -------------- |
| 89 | |
Junio C Hamano | ed7f4f6 | 2007-05-20 09:09:09 | [diff] [blame] | 90 | Modify some files, then add their updated contents to the index: |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 91 | |
| 92 | ------------------------------------------------ |
Junio C Hamano | 79770b6 | 2007-01-07 07:43:58 | [diff] [blame] | 93 | $ git add file1 file2 file3 |
Junio C Hamano | ed7f4f6 | 2007-05-20 09:09:09 | [diff] [blame] | 94 | ------------------------------------------------ |
| 95 | |
| 96 | You are now ready to commit. You can see what is about to be committed |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 97 | using 'git diff' with the --cached option: |
Junio C Hamano | ed7f4f6 | 2007-05-20 09:09:09 | [diff] [blame] | 98 | |
| 99 | ------------------------------------------------ |
| 100 | $ git diff --cached |
| 101 | ------------------------------------------------ |
| 102 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 103 | (Without --cached, 'git diff' will show you any changes that |
Junio C Hamano | ed7f4f6 | 2007-05-20 09:09:09 | [diff] [blame] | 104 | you've made but not yet added to the index.) You can also get a brief |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 105 | summary of the situation with 'git status': |
Junio C Hamano | ed7f4f6 | 2007-05-20 09:09:09 | [diff] [blame] | 106 | |
| 107 | ------------------------------------------------ |
| 108 | $ git status |
| 109 | # On branch master |
| 110 | # Changes to be committed: |
| 111 | # (use "git reset HEAD <file>..." to unstage) |
| 112 | # |
| 113 | # modified: file1 |
| 114 | # modified: file2 |
| 115 | # modified: file3 |
| 116 | # |
| 117 | ------------------------------------------------ |
| 118 | |
| 119 | If you need to make any further adjustments, do so now, and then add any |
| 120 | newly modified content to the index. Finally, commit your changes with: |
| 121 | |
| 122 | ------------------------------------------------ |
Junio C Hamano | eb69295 | 2007-01-03 22:02:12 | [diff] [blame] | 123 | $ git commit |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 124 | ------------------------------------------------ |
| 125 | |
Junio C Hamano | 6fb124c | 2008-06-13 10:04:01 | [diff] [blame] | 126 | This will again prompt you for a message describing the change, and then |
Junio C Hamano | ed7f4f6 | 2007-05-20 09:09:09 | [diff] [blame] | 127 | record a new version of the project. |
Junio C Hamano | 79770b6 | 2007-01-07 07:43:58 | [diff] [blame] | 128 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 129 | Alternatively, instead of running 'git add' beforehand, you can use |
Junio C Hamano | 699660b | 2006-11-29 20:40:10 | [diff] [blame] | 130 | |
| 131 | ------------------------------------------------ |
| 132 | $ git commit -a |
| 133 | ------------------------------------------------ |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 134 | |
Junio C Hamano | ed7f4f6 | 2007-05-20 09:09:09 | [diff] [blame] | 135 | which will automatically notice any modified (but not new) files, add |
| 136 | them to the index, and commit, all in one step. |
Junio C Hamano | 79770b6 | 2007-01-07 07:43:58 | [diff] [blame] | 137 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 138 | A note on commit messages: Though not required, it's a good idea to |
| 139 | begin the commit message with a single short (less than 50 character) |
| 140 | line summarizing the change, followed by a blank line and then a more |
| 141 | thorough description. Tools that turn commits into email, for |
Junio C Hamano | eb69295 | 2007-01-03 22:02:12 | [diff] [blame] | 142 | example, use the first line on the Subject: line and the rest of the |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 143 | commit in the body. |
| 144 | |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 145 | Git tracks content not files |
| 146 | ---------------------------- |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 147 | |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 148 | Many revision control systems provide an `add` command that tells the |
| 149 | system to start tracking changes to a new file. Git's `add` command |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 150 | does something simpler and more powerful: 'git add' is used both for new |
Junio C Hamano | ed7f4f6 | 2007-05-20 09:09:09 | [diff] [blame] | 151 | and newly modified files, and in both cases it takes a snapshot of the |
| 152 | given files and stages that content in the index, ready for inclusion in |
| 153 | the next commit. |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 154 | |
Junio C Hamano | f614c64 | 2007-06-11 01:21:54 | [diff] [blame] | 155 | Viewing project history |
| 156 | ----------------------- |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 157 | |
| 158 | At any point you can view the history of your changes using |
| 159 | |
| 160 | ------------------------------------------------ |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 161 | $ git log |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 162 | ------------------------------------------------ |
| 163 | |
| 164 | If you also want to see complete diffs at each step, use |
| 165 | |
| 166 | ------------------------------------------------ |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 167 | $ git log -p |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 168 | ------------------------------------------------ |
| 169 | |
Junio C Hamano | eb69295 | 2007-01-03 22:02:12 | [diff] [blame] | 170 | Often the overview of the change is useful to get a feel of |
| 171 | each step |
| 172 | |
| 173 | ------------------------------------------------ |
| 174 | $ git log --stat --summary |
| 175 | ------------------------------------------------ |
| 176 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 177 | Managing branches |
| 178 | ----------------- |
| 179 | |
| 180 | A single git repository can maintain multiple branches of |
| 181 | development. To create a new branch named "experimental", use |
| 182 | |
| 183 | ------------------------------------------------ |
| 184 | $ git branch experimental |
| 185 | ------------------------------------------------ |
| 186 | |
| 187 | If you now run |
| 188 | |
| 189 | ------------------------------------------------ |
| 190 | $ git branch |
| 191 | ------------------------------------------------ |
| 192 | |
| 193 | you'll get a list of all existing branches: |
| 194 | |
| 195 | ------------------------------------------------ |
| 196 | experimental |
| 197 | * master |
| 198 | ------------------------------------------------ |
| 199 | |
| 200 | The "experimental" branch is the one you just created, and the |
| 201 | "master" branch is a default branch that was created for you |
| 202 | automatically. The asterisk marks the branch you are currently on; |
| 203 | type |
| 204 | |
| 205 | ------------------------------------------------ |
| 206 | $ git checkout experimental |
| 207 | ------------------------------------------------ |
| 208 | |
| 209 | to switch to the experimental branch. Now edit a file, commit the |
| 210 | change, and switch back to the master branch: |
| 211 | |
| 212 | ------------------------------------------------ |
| 213 | (edit file) |
| 214 | $ git commit -a |
| 215 | $ git checkout master |
| 216 | ------------------------------------------------ |
| 217 | |
| 218 | Check that the change you made is no longer visible, since it was |
| 219 | made on the experimental branch and you're back on the master branch. |
| 220 | |
| 221 | You can make a different change on the master branch: |
| 222 | |
| 223 | ------------------------------------------------ |
| 224 | (edit file) |
| 225 | $ git commit -a |
| 226 | ------------------------------------------------ |
| 227 | |
| 228 | at this point the two branches have diverged, with different changes |
Junio C Hamano | 0df3434 | 2006-11-22 08:28:50 | [diff] [blame] | 229 | made in each. To merge the changes made in experimental into master, run |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 230 | |
| 231 | ------------------------------------------------ |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 232 | $ git merge experimental |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 233 | ------------------------------------------------ |
| 234 | |
| 235 | If the changes don't conflict, you're done. If there are conflicts, |
| 236 | markers will be left in the problematic files showing the conflict; |
| 237 | |
| 238 | ------------------------------------------------ |
| 239 | $ git diff |
| 240 | ------------------------------------------------ |
| 241 | |
| 242 | will show this. Once you've edited the files to resolve the |
| 243 | conflicts, |
| 244 | |
| 245 | ------------------------------------------------ |
| 246 | $ git commit -a |
| 247 | ------------------------------------------------ |
| 248 | |
| 249 | will commit the result of the merge. Finally, |
| 250 | |
| 251 | ------------------------------------------------ |
| 252 | $ gitk |
| 253 | ------------------------------------------------ |
| 254 | |
| 255 | will show a nice graphical representation of the resulting history. |
| 256 | |
Junio C Hamano | eb69295 | 2007-01-03 22:02:12 | [diff] [blame] | 257 | At this point you could delete the experimental branch with |
| 258 | |
| 259 | ------------------------------------------------ |
| 260 | $ git branch -d experimental |
| 261 | ------------------------------------------------ |
| 262 | |
| 263 | This command ensures that the changes in the experimental branch are |
| 264 | already in the current branch. |
| 265 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 266 | If you develop on a branch crazy-idea, then regret it, you can always |
| 267 | delete the branch with |
| 268 | |
| 269 | ------------------------------------- |
| 270 | $ git branch -D crazy-idea |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 271 | ------------------------------------- |
| 272 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 273 | Branches are cheap and easy, so this is a good way to try something |
| 274 | out. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 275 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 276 | Using git for collaboration |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 277 | --------------------------- |
| 278 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 279 | Suppose that Alice has started a new project with a git repository in |
| 280 | /home/alice/project, and that Bob, who has a home directory on the |
| 281 | same machine, wants to contribute. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 282 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 283 | Bob begins with: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 284 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 285 | ------------------------------------------------ |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 286 | bob$ git clone /home/alice/project myrepo |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 287 | ------------------------------------------------ |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 288 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 289 | This creates a new directory "myrepo" containing a clone of Alice's |
| 290 | repository. The clone is on an equal footing with the original |
Junio C Hamano | 341071d | 2006-06-04 07:24:48 | [diff] [blame] | 291 | project, possessing its own copy of the original project's history. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 292 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 293 | Bob then makes some changes and commits them: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 294 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 295 | ------------------------------------------------ |
| 296 | (edit files) |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 297 | bob$ git commit -a |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 298 | (repeat as necessary) |
| 299 | ------------------------------------------------ |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 300 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 301 | When he's ready, he tells Alice to pull changes from the repository |
| 302 | at /home/bob/myrepo. She does this with: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 303 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 304 | ------------------------------------------------ |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 305 | alice$ cd /home/alice/project |
| 306 | alice$ git pull /home/bob/myrepo master |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 307 | ------------------------------------------------ |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 308 | |
Junio C Hamano | f98fd88 | 2006-11-26 07:28:29 | [diff] [blame] | 309 | This merges the changes from Bob's "master" branch into Alice's |
| 310 | current branch. If Alice has made her own changes in the meantime, |
Junio C Hamano | 20d47e3 | 2009-01-26 06:36:02 | [diff] [blame] | 311 | then she may need to manually fix any conflicts. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 312 | |
Junio C Hamano | f98fd88 | 2006-11-26 07:28:29 | [diff] [blame] | 313 | The "pull" command thus performs two operations: it fetches changes |
| 314 | from a remote branch, then merges them into the current branch. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 315 | |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 316 | Note that in general, Alice would want her local changes committed before |
| 317 | initiating this "pull". If Bob's work conflicts with what Alice did since |
| 318 | their histories forked, Alice will use her working tree and the index to |
| 319 | resolve conflicts, and existing local changes will interfere with the |
| 320 | conflict resolution process (git will still perform the fetch but will |
| 321 | refuse to merge --- Alice will have to get rid of her local changes in |
| 322 | some way and pull again when this happens). |
| 323 | |
| 324 | Alice can peek at what Bob did without merging first, using the "fetch" |
| 325 | command; this allows Alice to inspect what Bob did, using a special |
| 326 | symbol "FETCH_HEAD", in order to determine if he has anything worth |
| 327 | pulling, like this: |
| 328 | |
| 329 | ------------------------------------------------ |
| 330 | alice$ git fetch /home/bob/myrepo master |
Junio C Hamano | a387df3 | 2008-08-29 08:56:58 | [diff] [blame] | 331 | alice$ git log -p HEAD..FETCH_HEAD |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 332 | ------------------------------------------------ |
| 333 | |
| 334 | This operation is safe even if Alice has uncommitted local changes. |
Junio C Hamano | 73d812c | 2009-07-01 02:33:06 | [diff] [blame] | 335 | The range notation "HEAD..FETCH_HEAD" means "show everything that is reachable |
| 336 | from the FETCH_HEAD but exclude anything that is reachable from HEAD". |
Junio C Hamano | a387df3 | 2008-08-29 08:56:58 | [diff] [blame] | 337 | Alice already knows everything that leads to her current state (HEAD), |
Junio C Hamano | 73d812c | 2009-07-01 02:33:06 | [diff] [blame] | 338 | and reviews what Bob has in his state (FETCH_HEAD) that she has not |
| 339 | seen with this command. |
Junio C Hamano | a387df3 | 2008-08-29 08:56:58 | [diff] [blame] | 340 | |
| 341 | If Alice wants to visualize what Bob did since their histories forked |
| 342 | she can issue the following command: |
| 343 | |
| 344 | ------------------------------------------------ |
| 345 | $ gitk HEAD..FETCH_HEAD |
| 346 | ------------------------------------------------ |
| 347 | |
| 348 | This uses the same two-dot range notation we saw earlier with 'git log'. |
| 349 | |
| 350 | Alice may want to view what both of them did since they forked. |
| 351 | She can use three-dot form instead of the two-dot form: |
| 352 | |
| 353 | ------------------------------------------------ |
| 354 | $ gitk HEAD...FETCH_HEAD |
| 355 | ------------------------------------------------ |
| 356 | |
| 357 | This means "show everything that is reachable from either one, but |
| 358 | exclude anything that is reachable from both of them". |
| 359 | |
| 360 | Please note that these range notation can be used with both gitk |
| 361 | and "git log". |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 362 | |
| 363 | After inspecting what Bob did, if there is nothing urgent, Alice may |
| 364 | decide to continue working without pulling from Bob. If Bob's history |
| 365 | does have something Alice would immediately need, Alice may choose to |
| 366 | stash her work-in-progress first, do a "pull", and then finally unstash |
| 367 | her work-in-progress on top of the resulting history. |
| 368 | |
Junio C Hamano | 35bd025 | 2007-01-17 05:40:22 | [diff] [blame] | 369 | When you are working in a small closely knit group, it is not |
| 370 | unusual to interact with the same repository over and over |
| 371 | again. By defining 'remote' repository shorthand, you can make |
| 372 | it easier: |
| 373 | |
| 374 | ------------------------------------------------ |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 375 | alice$ git remote add bob /home/bob/myrepo |
Junio C Hamano | 35bd025 | 2007-01-17 05:40:22 | [diff] [blame] | 376 | ------------------------------------------------ |
| 377 | |
Junio C Hamano | 73d812c | 2009-07-01 02:33:06 | [diff] [blame] | 378 | With this, Alice can perform the first part of the "pull" operation |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 379 | alone using the 'git fetch' command without merging them with her own |
Junio C Hamano | 73d812c | 2009-07-01 02:33:06 | [diff] [blame] | 380 | branch, using: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 381 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 382 | ------------------------------------- |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 383 | alice$ git fetch bob |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 384 | ------------------------------------- |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 385 | |
Junio C Hamano | 35bd025 | 2007-01-17 05:40:22 | [diff] [blame] | 386 | Unlike the longhand form, when Alice fetches from Bob using a |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 387 | remote repository shorthand set up with 'git remote', what was |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 388 | fetched is stored in a remote-tracking branch, in this case |
Junio C Hamano | 35bd025 | 2007-01-17 05:40:22 | [diff] [blame] | 389 | `bob/master`. So after this: |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 390 | |
| 391 | ------------------------------------- |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 392 | alice$ git log -p master..bob/master |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 393 | ------------------------------------- |
| 394 | |
| 395 | shows a list of all the changes that Bob made since he branched from |
| 396 | Alice's master branch. |
| 397 | |
Junio C Hamano | 35bd025 | 2007-01-17 05:40:22 | [diff] [blame] | 398 | After examining those changes, Alice |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 399 | could merge the changes into her master branch: |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 400 | |
| 401 | ------------------------------------- |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 402 | alice$ git merge bob/master |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 403 | ------------------------------------- |
| 404 | |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 405 | This `merge` can also be done by 'pulling from her own remote-tracking |
| 406 | branch', like this: |
Junio C Hamano | f98fd88 | 2006-11-26 07:28:29 | [diff] [blame] | 407 | |
| 408 | ------------------------------------- |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 409 | alice$ git pull . remotes/bob/master |
Junio C Hamano | f98fd88 | 2006-11-26 07:28:29 | [diff] [blame] | 410 | ------------------------------------- |
| 411 | |
Junio C Hamano | 35bd025 | 2007-01-17 05:40:22 | [diff] [blame] | 412 | Note that git pull always merges into the current branch, |
Junio C Hamano | a638742 | 2007-08-25 03:54:27 | [diff] [blame] | 413 | regardless of what else is given on the command line. |
Junio C Hamano | f98fd88 | 2006-11-26 07:28:29 | [diff] [blame] | 414 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 415 | Later, Bob can update his repo with Alice's latest changes using |
| 416 | |
| 417 | ------------------------------------- |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 418 | bob$ git pull |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 419 | ------------------------------------- |
| 420 | |
| 421 | Note that he doesn't need to give the path to Alice's repository; |
| 422 | when Bob cloned Alice's repository, git stored the location of her |
Junio C Hamano | d3361ad | 2007-01-01 03:20:24 | [diff] [blame] | 423 | repository in the repository configuration, and that location is |
| 424 | used for pulls: |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 425 | |
| 426 | ------------------------------------- |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 427 | bob$ git config --get remote.origin.url |
Junio C Hamano | 330aae6 | 2007-07-06 17:01:58 | [diff] [blame] | 428 | /home/alice/project |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 429 | ------------------------------------- |
| 430 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 431 | (The complete configuration created by 'git clone' is visible using |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 432 | `git config -l`, and the linkgit:git-config[1] man page |
Junio C Hamano | d3361ad | 2007-01-01 03:20:24 | [diff] [blame] | 433 | explains the meaning of each option.) |
| 434 | |
| 435 | Git also keeps a pristine copy of Alice's master branch under the |
| 436 | name "origin/master": |
| 437 | |
| 438 | ------------------------------------- |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 439 | bob$ git branch -r |
Junio C Hamano | d3361ad | 2007-01-01 03:20:24 | [diff] [blame] | 440 | origin/master |
| 441 | ------------------------------------- |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 442 | |
| 443 | If Bob later decides to work from a different host, he can still |
| 444 | perform clones and pulls using the ssh protocol: |
| 445 | |
| 446 | ------------------------------------- |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 447 | bob$ git clone alice.org:/home/alice/project myrepo |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 448 | ------------------------------------- |
| 449 | |
| 450 | Alternatively, git has a native protocol, or can use rsync or http; |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 451 | see linkgit:git-pull[1] for details. |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 452 | |
| 453 | Git can also be used in a CVS-like mode, with a central repository |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 454 | that various users push changes to; see linkgit:git-push[1] and |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 455 | linkgit:gitcvs-migration[7]. |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 456 | |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 457 | Exploring history |
| 458 | ----------------- |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 459 | |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 460 | Git history is represented as a series of interrelated commits. We |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 461 | have already seen that the 'git log' command can list those commits. |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 462 | Note that first line of each git log entry also gives a name for the |
| 463 | commit: |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 464 | |
| 465 | ------------------------------------- |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 466 | $ git log |
| 467 | commit c82a22c39cbc32576f64f5c6b3f24b99ea8149c7 |
| 468 | Author: Junio C Hamano <junkio@cox.net> |
| 469 | Date: Tue May 16 17:18:22 2006 -0700 |
| 470 | |
| 471 | merge-base: Clarify the comments on post processing. |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 472 | ------------------------------------- |
| 473 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 474 | We can give this name to 'git show' to see the details about this |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 475 | commit. |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 476 | |
| 477 | ------------------------------------- |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 478 | $ git show c82a22c39cbc32576f64f5c6b3f24b99ea8149c7 |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 479 | ------------------------------------- |
| 480 | |
Junio C Hamano | eb69295 | 2007-01-03 22:02:12 | [diff] [blame] | 481 | But there are other ways to refer to commits. You can use any initial |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 482 | part of the name that is long enough to uniquely identify the commit: |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 483 | |
| 484 | ------------------------------------- |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 485 | $ git show c82a22c39c # the first few characters of the name are |
| 486 | # usually enough |
| 487 | $ git show HEAD # the tip of the current branch |
| 488 | $ git show experimental # the tip of the "experimental" branch |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 489 | ------------------------------------- |
| 490 | |
Junio C Hamano | eb69295 | 2007-01-03 22:02:12 | [diff] [blame] | 491 | Every commit usually has one "parent" commit |
| 492 | which points to the previous state of the project: |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 493 | |
| 494 | ------------------------------------- |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 495 | $ git show HEAD^ # to see the parent of HEAD |
| 496 | $ git show HEAD^^ # to see the grandparent of HEAD |
| 497 | $ git show HEAD~4 # to see the great-great grandparent of HEAD |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 498 | ------------------------------------- |
| 499 | |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 500 | Note that merge commits may have more than one parent: |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 501 | |
| 502 | ------------------------------------- |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 503 | $ git show HEAD^1 # show the first parent of HEAD (same as HEAD^) |
| 504 | $ git show HEAD^2 # show the second parent of HEAD |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 505 | ------------------------------------- |
| 506 | |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 507 | You can also give commits names of your own; after running |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 508 | |
| 509 | ------------------------------------- |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 510 | $ git tag v2.5 1b2e1d63ff |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 511 | ------------------------------------- |
| 512 | |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 513 | you can refer to 1b2e1d63ff by the name "v2.5". If you intend to |
| 514 | share this name with other people (for example, to identify a release |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 515 | version), you should create a "tag" object, and perhaps sign it; see |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 516 | linkgit:git-tag[1] for details. |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 517 | |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 518 | Any git command that needs to know a commit can take any of these |
| 519 | names. For example: |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 520 | |
| 521 | ------------------------------------- |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 522 | $ git diff v2.5 HEAD # compare the current HEAD to v2.5 |
| 523 | $ git branch stable v2.5 # start a new branch named "stable" based |
| 524 | # at v2.5 |
| 525 | $ git reset --hard HEAD^ # reset your current branch and working |
Junio C Hamano | 33db437 | 2006-06-07 19:51:45 | [diff] [blame] | 526 | # directory to its state at HEAD^ |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 527 | ------------------------------------- |
| 528 | |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 529 | Be careful with that last command: in addition to losing any changes |
| 530 | in the working directory, it will also remove all later commits from |
| 531 | this branch. If this branch is the only branch containing those |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 532 | commits, they will be lost. Also, don't use 'git reset' on a |
Junio C Hamano | ee1e428 | 2007-02-04 08:32:04 | [diff] [blame] | 533 | publicly-visible branch that other developers pull from, as it will |
| 534 | force needless merges on other developers to clean up the history. |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 535 | If you need to undo changes that you have pushed, use 'git revert' |
Junio C Hamano | 16cf158 | 2007-02-05 07:21:48 | [diff] [blame] | 536 | instead. |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 537 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 538 | The 'git grep' command can search for strings in any version of your |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 539 | project, so |
| 540 | |
| 541 | ------------------------------------- |
| 542 | $ git grep "hello" v2.5 |
| 543 | ------------------------------------- |
| 544 | |
Junio C Hamano | 341071d | 2006-06-04 07:24:48 | [diff] [blame] | 545 | searches for all occurrences of "hello" in v2.5. |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 546 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 547 | If you leave out the commit name, 'git grep' will search any of the |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 548 | files it manages in your current directory. So |
| 549 | |
| 550 | ------------------------------------- |
| 551 | $ git grep "hello" |
| 552 | ------------------------------------- |
| 553 | |
| 554 | is a quick way to search just the files that are tracked by git. |
| 555 | |
| 556 | Many git commands also take sets of commits, which can be specified |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 557 | in a number of ways. Here are some examples with 'git log': |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 558 | |
| 559 | ------------------------------------- |
| 560 | $ git log v2.5..v2.6 # commits between v2.5 and v2.6 |
| 561 | $ git log v2.5.. # commits since v2.5 |
| 562 | $ git log --since="2 weeks ago" # commits from the last 2 weeks |
| 563 | $ git log v2.5.. Makefile # commits since v2.5 which modify |
| 564 | # Makefile |
| 565 | ------------------------------------- |
| 566 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 567 | You can also give 'git log' a "range" of commits where the first is not |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 568 | necessarily an ancestor of the second; for example, if the tips of |
Junio C Hamano | 73d812c | 2009-07-01 02:33:06 | [diff] [blame] | 569 | the branches "stable" and "master" diverged from a common |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 570 | commit some time ago, then |
| 571 | |
| 572 | ------------------------------------- |
Junio C Hamano | 73d812c | 2009-07-01 02:33:06 | [diff] [blame] | 573 | $ git log stable..master |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 574 | ------------------------------------- |
| 575 | |
Junio C Hamano | 73d812c | 2009-07-01 02:33:06 | [diff] [blame] | 576 | will list commits made in the master branch but not in the |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 577 | stable branch, while |
| 578 | |
| 579 | ------------------------------------- |
Junio C Hamano | 73d812c | 2009-07-01 02:33:06 | [diff] [blame] | 580 | $ git log master..stable |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 581 | ------------------------------------- |
| 582 | |
| 583 | will show the list of commits made on the stable branch but not |
Junio C Hamano | 73d812c | 2009-07-01 02:33:06 | [diff] [blame] | 584 | the master branch. |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 585 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 586 | The 'git log' command has a weakness: it must present commits in a |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 587 | list. When the history has lines of development that diverged and |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 588 | then merged back together, the order in which 'git log' presents |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 589 | those commits is meaningless. |
| 590 | |
Junio C Hamano | 4fbdd44 | 2009-01-06 05:56:24 | [diff] [blame] | 591 | Most projects with multiple contributors (such as the Linux kernel, |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 592 | or git itself) have frequent merges, and 'gitk' does a better job of |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 593 | visualizing their history. For example, |
| 594 | |
| 595 | ------------------------------------- |
| 596 | $ gitk --since="2 weeks ago" drivers/ |
| 597 | ------------------------------------- |
| 598 | |
| 599 | allows you to browse any commits from the last 2 weeks of commits |
Junio C Hamano | bb8fb05 | 2006-05-30 07:21:12 | [diff] [blame] | 600 | that modified files under the "drivers" directory. (Note: you can |
| 601 | adjust gitk's fonts by holding down the control key while pressing |
| 602 | "-" or "+".) |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 603 | |
| 604 | Finally, most commands that take filenames will optionally allow you |
| 605 | to precede any filename by a commit, to specify a particular version |
Junio C Hamano | bb8fb05 | 2006-05-30 07:21:12 | [diff] [blame] | 606 | of the file: |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 607 | |
| 608 | ------------------------------------- |
| 609 | $ git diff v2.5:Makefile HEAD:Makefile.in |
| 610 | ------------------------------------- |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 611 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 612 | You can also use 'git show' to see any such file: |
Junio C Hamano | bb8fb05 | 2006-05-30 07:21:12 | [diff] [blame] | 613 | |
| 614 | ------------------------------------- |
Junio C Hamano | eb69295 | 2007-01-03 22:02:12 | [diff] [blame] | 615 | $ git show v2.5:Makefile |
Junio C Hamano | bb8fb05 | 2006-05-30 07:21:12 | [diff] [blame] | 616 | ------------------------------------- |
| 617 | |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 618 | Next Steps |
| 619 | ---------- |
| 620 | |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 621 | This tutorial should be enough to perform basic distributed revision |
| 622 | control for your projects. However, to fully understand the depth |
| 623 | and power of git you need to understand two simple ideas on which it |
| 624 | is based: |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 625 | |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 626 | * The object database is the rather elegant system used to |
| 627 | store the history of your project--files, directories, and |
| 628 | commits. |
| 629 | |
| 630 | * The index file is a cache of the state of a directory tree, |
| 631 | used to create commits, check out working directories, and |
| 632 | hold the various trees involved in a merge. |
| 633 | |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 634 | Part two of this tutorial explains the object |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 635 | database, the index file, and a few other odds and ends that you'll |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 636 | need to make the most of git. You can find it at linkgit:gittutorial-2[7]. |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 637 | |
Junio C Hamano | ed7f4f6 | 2007-05-20 09:09:09 | [diff] [blame] | 638 | If you don't want to continue with that right away, a few other |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 639 | digressions that may be interesting at this point are: |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 640 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 641 | * linkgit:git-format-patch[1], linkgit:git-am[1]: These convert |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 642 | series of git commits into emailed patches, and vice versa, |
Junio C Hamano | 4fbdd44 | 2009-01-06 05:56:24 | [diff] [blame] | 643 | useful for projects such as the Linux kernel which rely heavily |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 644 | on emailed patches. |
| 645 | |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 646 | * linkgit:git-bisect[1]: When there is a regression in your |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 647 | project, one way to track down the bug is by searching through |
| 648 | the history to find the exact commit that's to blame. Git bisect |
| 649 | can help you perform a binary search for that commit. It is |
| 650 | smart enough to perform a close-to-optimal search even in the |
| 651 | case of complex non-linear history with lots of merged branches. |
| 652 | |
Junio C Hamano | 804b521 | 2009-06-07 16:05:03 | [diff] [blame] | 653 | * linkgit:gitworkflows[7]: Gives an overview of recommended |
| 654 | workflows. |
| 655 | |
Junio C Hamano | 341071d | 2006-06-04 07:24:48 | [diff] [blame] | 656 | * link:everyday.html[Everyday GIT with 20 Commands Or So] |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 657 | |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 658 | * linkgit:gitcvs-migration[7]: Git for CVS users. |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 659 | |
| 660 | SEE ALSO |
| 661 | -------- |
| 662 | linkgit:gittutorial-2[7], |
| 663 | linkgit:gitcvs-migration[7], |
Junio C Hamano | 9e1793f | 2008-06-02 07:31:16 | [diff] [blame] | 664 | linkgit:gitcore-tutorial[7], |
| 665 | linkgit:gitglossary[7], |
Junio C Hamano | f66ecee | 2008-11-17 18:25:43 | [diff] [blame] | 666 | linkgit:git-help[1], |
Junio C Hamano | 804b521 | 2009-06-07 16:05:03 | [diff] [blame] | 667 | linkgit:gitworkflows[7], |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 668 | link:everyday.html[Everyday git], |
| 669 | link:user-manual.html[The Git User's Manual] |
| 670 | |
| 671 | GIT |
| 672 | --- |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 673 | Part of the linkgit:git[1] suite. |