|
17 | 17 | "- Understand how to view the history of commits in a Git repository using the `git log` command\n",
|
18 | 18 | "- Learn to navigate through the log output using the paging commands\n",
|
19 | 19 | "- Use the `gif diff` command to view differences between commits and changes in the working directory\n",
|
20 |
| - "- Differentiate between various states of changes: unstaged, stages and committed\n", |
| 20 | + "- Differentiate between various states of changes: unstaged, staged and committed\n", |
21 | 21 | "- Explore GUI tools for viewing differences in files \n",
|
22 | 22 | "\n",
|
23 | 23 | "\n",
|
|
66 | 66 | "\n",
|
67 | 67 | "The log contains one entry for each commit. The commit messages for the\n",
|
68 | 68 | "commits are included, as well as details of who made the commit. The name and email address\n",
|
69 |
| - "are those that were given when configuring Git (see the episode Setting up Git and GitHub.\n", |
| 69 | + "are those that were given when configuring Git (see the episode Setting up Git and GitHub).\n", |
70 | 70 | "\n",
|
71 | 71 | "In addition, each commit has a unique **identifier** associated to it, which is the long\n",
|
72 | 72 | "random-looking string next to each commit. (The identifiers for your\n",
|
|
196 | 196 | "\n",
|
197 | 197 | "### Understanding the output of `git diff`\n",
|
198 | 198 | "The output of `git diff`, as shown above, is cryptic because it is actually a series of commands for tools like editors and `patch` telling them how to reconstruct one file given the other. If we break it down into pieces:\n",
|
199 |
| - "1. The 'diff' for each file begins with a line like `diff --git a/<filename> b/<filename>`. It tells us that Git is producing output similar to the Unix `diff` command, comparing the old and new versions of thefile `<filename>`. In the example above, the output starts with the diff for `Commit-good-practice.md` until just before the line `diff --git a/Git-cheatsheet.md b/Git-cheatsheet.md`, at which point it switches to the diff for `Git-cheatsheet.md`.\n", |
200 |
| - "2. The next few lines in each file's diff tell exactly which versions of the file Git is comparing. Confusingly, it looks like it contains commit identifiers, but these are in face different, computer-generated labels for the versions of the files.\n", |
| 199 | + "1. The 'diff' for each file begins with a line like `diff --git a/<filename> b/<filename>`. It tells us that Git is producing output similar to the Unix `diff` command, comparing the old and new versions of the file `<filename>`. In the example above, the output starts with the diff for `Commit-good-practice.md` until just before the line `diff --git a/Git-cheatsheet.md b/Git-cheatsheet.md`, at which point it switches to the diff for `Git-cheatsheet.md`.\n", |
| 200 | + "2. The next few lines in each file's diff tell exactly which versions of the file Git is comparing. Confusingly, it looks like it contains commit identifiers, but these are in fact different, computer-generated labels for the versions of the files.\n", |
201 | 201 | "3. The remaining lines, beginning `@@`, are the most interesting: they show us the actual differences and the lines on which they occur. In particular, the `+` marker in the first column shows where we added a line. If we had lines that were removed, these would be marked with `-`.\n",
|
202 | 202 | "\n",
|
203 | 203 | "If we wanted to view just the diff for the file `Git-cheatsheet.md` we would\n",
|
|
279 | 279 | " changes that have been made to `Git-cheatsheet.md` since commit `ad56194`\n",
|
280 | 280 | " i.e. the changes required to go from 3 commits earlier to the current commit.\n",
|
281 | 281 | "\n",
|
282 |
| - "* The command `git diff HEAD~3 HEAD~2` would give the changes required to fo\n", |
| 282 | + "* The command `git diff HEAD~3 HEAD~2` would give the changes required to get\n", |
283 | 283 | " from commit `HEAD~3` (`ad56194`) to `HEAD~2` (`34c19f2`). In other words, it\n",
|
284 | 284 | " just gives the changes applied back when we did commit `34c19f2`.\n",
|
285 | 285 | "\n",
|
286 | 286 | "\n",
|
287 | 287 | "### Exercise\n",
|
288 |
| - "Verify the claims in the three bullet point examples given above, checking the outputs of `git diff` agree for the `HEAD` versions and the regular commit identifier versions. _Note: make sure to use the commit identifiersfound in your own log, not the ones that feature in the example output above!_\n", |
| 288 | + "Verify the claims in the three bullet point examples given above, checking the outputs of `git diff` agree for the `HEAD` versions and the regular commit identifier versions. _Note: make sure to use the commit identifiers found in your own log, not the ones that feature in the example output above!_\n", |
289 | 289 | "\n",
|
290 | 290 | "\n",
|
291 | 291 | "## Working tree and staging area diffs\n",
|
|
386 | 386 | "\n",
|
387 | 387 | "\n",
|
388 | 388 | "### Exercise\n",
|
389 |
| - "First follow the steps above, so that you end up with entries about `git log` and `git log --oneline` in `Git-cheatsheet.md` that are staged but not committed.Now add a new entry to the cheatsheet about `git log -n`, but don't stage it. Now do the following:\n", |
| 389 | + "First follow the steps above, so that you end up with entries about `git log` and `git log --oneline` in `Git-cheatsheet.md` that are staged but not committed.Now add a new entry to the cheatsheet about `git log -n`, but don't stage it. Next do the following:\n", |
390 | 390 | "* Run `git diff Git-cheatsheet.md`\n",
|
391 | 391 | "* Run `git status`\n",
|
392 | 392 | "Can you explain what the output from these commands is saying, and why we get it? Once you're happy you understand what's going on, complete the task of adding the material about `git log` to the cheatsheet by making an appropriate commit, making sure to include the entry about `git log -n`.\n",
|
|
404 | 404 | "For VS Code users, the following links may be of help:\n",
|
405 | 405 | "* View the diffs for files that have not been staged, or have been staged but not committed <https://code.visualstudio.com/docs/sourcecontrol/overview#_working-in-a-git-repository>.\n",
|
406 | 406 | "* View the commit history of a file: <https://code.visualstudio.com/docs/sourcecontrol/overview#_timeline-view>. This also suggests some extensions for VS Code to make working with Git more graphical.\n",
|
407 |
| - "* Displaying diffs by selecting files to compare: <https://code.visualstudio.com/docs/sourcecontrol/overview#_viewing-diffs>. Note that the method described in this link can be used on the 'timeline' described in the previous link: simply right-click on different commits inthe timeline for a given file to see the changes between the commits.\n", |
| 407 | + "* Displaying diffs by selecting files to compare: <https://code.visualstudio.com/docs/sourcecontrol/overview#_viewing-diffs>. Note that the method described in this link can be used on the 'timeline' described in the previous link: simply right-click on different commits in the timeline for a given file to see the changes between the commits.\n", |
408 | 408 | "\n",
|
409 | 409 | "## Summary Quiz"
|
410 | 410 | ]
|
|
0 commit comments