Skip to content

Commit 66ee2c5

Browse files
committed
simplify explanations of git diff head
1 parent f179db0 commit 66ee2c5

2 files changed

Lines changed: 12 additions & 18 deletions

File tree

episodes/04-changes.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,6 @@ but we haven't told Git we will want to save those changes
286286
nor have we saved them (which we do with `git commit`).
287287
So let's do that now. It is good practice to always review
288288
our changes before saving them. We do this using `git diff`.
289-
This shows us the differences between the current state
290-
of the file and the most recently saved version:
291289

292290
```bash
293291
$ git diff
@@ -447,12 +445,9 @@ $ git add guacamole.md
447445
$ git diff
448446
```
449447

450-
There is no output:
451-
as far as Git can tell,
452-
there's no difference between what it's been asked to save permanently
453-
and what's currently in the directory.
454-
However,
455-
if we do this:
448+
There is no output. Without any arguments, `git diff` compares the working directory and the staging area. After `git add`, the two versions are identical and there is nothing to show.
449+
450+
However, if we do this:
456451

457452
```bash
458453
$ git diff --staged
@@ -473,10 +468,7 @@ index 315bf3a..b36abfd 100644
473468
## Instructions
474469
```
475470

476-
it shows us the difference between
477-
the last committed change
478-
and what's in the staging area.
479-
Let's save our changes:
471+
we can see that by adding the `--staged` argument to the command we are now comparing what’s in the staged area to the last committed change.
480472

481473
```bash
482474
$ git commit -m "Modify guacamole to the traditional recipe"

episodes/05-history.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ exercises: 0
2222
::::::::::::::::::::::::::::::::::::::::::::::::::
2323

2424
As we saw in the previous episode, we can refer to commits by their
25-
identifiers. You can refer to the *most recent commit* of the working
26-
directory by using the identifier `HEAD`.
25+
identifiers. Git also provides a special identifier called `HEAD`, which refers to the **most recent commit**.
2726

28-
We've been adding small changes at a time to `guacamole.md`, so it's easy to track our
29-
progress by looking, so let's do that using our `HEAD`s. Before we start,
30-
let's make a change to `guacamole.md`, adding yet another line.
27+
We can use `HEAD` together with commands we already know to examine our project’s history.
28+
29+
Before we start, let's make a change to `guacamole.md` so we have something
30+
to compare. We won’t save this change yet.
3131

3232
```bash
3333
$ nano guacamole.md
@@ -62,7 +62,9 @@ index b36abfd..0848c8d 100644
6262
+An ill-considered change
6363
```
6464

65-
Note that `HEAD` is the default option for `git diff`, so omitting it will not change the command's output at all (give it a try). However, the real power of `git diff` lies in its ability to compare with previous commits. For example, by adding `~1` (where "~" is "tilde", pronounced [**til**\-d*uh*]), we can look at the commit before `HEAD`.
65+
Here we have the difference between the file in our working directory and the most recently committed version.
66+
67+
We can also refer to earlier commits relative to `HEAD`. For example, by adding `~1` (where "~" is "tilde", pronounced [**til**\-d*uh*]), we can look at the commit before `HEAD`.
6668

6769
```bash
6870
$ git diff HEAD~1 guacamole.md

0 commit comments

Comments
 (0)