Skip to content

Commit

Permalink
Add in a section on git show and remove the incorrect git diff wording
Browse files Browse the repository at this point in the history
  • Loading branch information
astroDimitrios committed Dec 18, 2024
1 parent 4a5059f commit 5059b92
Showing 1 changed file with 55 additions and 3 deletions.
58 changes: 55 additions & 3 deletions episodes/05-history.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,37 @@ Programs with regular releases might add reference tags such as `v1.0`
to a specific commit to mark a new release.
These references can be used instead of a commit identifier such as `e48heu0`.

### `git show`

The `git show` command lets you view information for specific commits.
By default `git show` will show information for the latest commit
on the current branch.

```bash
$ git show
```

```output
commit cdb7fa654c3f5aee731a655e57f2ba74d9c74582 (HEAD -> forecast)
Author: Joanne Simpson <j.simpson@mo-weather.uk>
Date: Mon Nov 4 18:35:21 2024 +0000
Add in the temperature to the forecast and create the weather atlas file
diff --git a/atlas.md b/atlas.md
new file mode 100644
index 0000000..18fac28
--- /dev/null
+++ b/atlas.md
@@ -0,0 +1,5 @@
+# Weather Atlas
+
+- rain
+- sunshine
+- fog
:
```

## Identifying Commits

As we saw in the previous episode, we can refer to commits by their
Expand Down Expand Up @@ -245,9 +276,7 @@ index df0654a..b36abfd 100644
+An ill-considered change.
```

We could also use `git show` which shows us what changes we made at an older commit as
well as the commit message, rather than the *differences* between a commit and our
working directory that we see by using `git diff`.
We can also use identifiers with `git show`.

```bash
$ git show HEAD~2 forecast.md
Expand Down Expand Up @@ -342,6 +371,29 @@ index df0654a..93a3e13 100644
+An ill-considered change.
```

So far we have only been comparing a previous commit to the working copy.
To get a difference between two specific commits use both their IDs:

```bash
$ git diff d3e4637 62a9457 forecast.md
```

```output
diff --git a/forecast.md b/forecast.md
index 4c96be7..541eee7 100644
--- a/forecast.md
+++ b/forecast.md
@@ -2,7 +2,7 @@
## Today
-Cloudy with a chance of pizza.
+Cloudy with a chance of Sun.
## Tomorrow
```

::::::::::::::::::::::::::::::::::::::: challenge

## Understanding Workflow and History
Expand Down

0 comments on commit 5059b92

Please # to comment.