Skip to content

Commit

Permalink
#69 Reorder history to be after the break
Browse files Browse the repository at this point in the history
  • Loading branch information
astroDimitrios authored Feb 26, 2025
1 parent fa776f0 commit 7d4ed94
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 89 deletions.
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ episodes:
- 03-feature-branch.md
- 04-review.md
- Break.md
- 07-history.md
- 05-forks.md
- 06-conflict.md
- 07-history.md
- End.md
- 08-rebase.md
- 09-pre-commit.md
Expand Down
1 change: 0 additions & 1 deletion episodes/06-conflict.md
Original file line number Diff line number Diff line change
Expand Up @@ -576,4 +576,3 @@ no longer exists.
- The version control system does not allow people to overwrite each other's changes blindly, but highlights conflicts so that they can be resolved.

::::::::::::::::::::::::::::::::::::::::::::::::::

94 changes: 15 additions & 79 deletions episodes/07-history.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,96 +25,32 @@ commands to explore your history.

Your Git history will look different depending on the merge
strategy you use when merging PRs
and whether you allow merging `main` into a feature branch
like we did in the last episode to resolve the conflict.
and whether you allow merging `main` into a feature branch.
It's up to you and your team to decide which strategy is
best for your repository.

::: spoiler

## Viewing History

You have already learnt that we can use the
`git log` command to output the commit history
In the [Introduction to Version Control
with Git](https://www.astropython.com/git-novice/05-history.html) lesson you learnt that we can use the
`git log` command to view the commit history
of our repository.

```bash
$ git log
```

```output
commit acce45c86ece7fd4823ddc6c1addb43edf4c0794
Merge: e3fc783 ca8aca9
Author: Robert FitzRoy <[email protected]>
Date: Mon Sep 23 15:50:15 2024 +0100
Merge pull request #1 from MetOffice/mo-fitzroy-patch-1
Create CITATION.cff
commit ca8aca9f2f43a4d799eb5c9ce9596b42360faa8b
Author: Robert FitzRoy <[email protected]>
Date: Mon Sep 23 15:49:36 2024 +0100
Create CITATION.cff
commit e3fc783648222d5eef0739922b06794b8d690341
Author: Robert FitzRoy <[email protected]>
Date: Fri Sep 20 13:01:05 2024 +0100
Initial commit
```

This shows the first 3 commits to the `git-training-demo` repository (the full output isn't shown here because it's very long).
We can use certain flags with `git log` to better
visualise the history in graph form:

```bash
$ git log --decorate --oneline --graph
```

```output
* d800b46 (HEAD -> main, origin/main, origin/HEAD) Merge pull request #2 from MetOffice/mo-fitzroy-patch-2
|\
| * dbc944d Add pre-commit checks
|/
* acce45c Merge pull request #1 from MetOffice/mo-fitzroy-patch-1
|\
| * ca8aca9 Create CITATION.cff
|/
* e3fc783 Initial commit
```

The [GitHub Documentation for git log](https://git-scm.com/docs/git-log) has information on all the available flags.
The key here is `--graph` shows us the graphical
representation of our history on the left of the
terminal.
`*`'s are commits which are connected by lines.
The vertical lines represent links between commits.
The output above shows two feature branches each with
only one commit which were then merged back into
`main` via a pull request.

You can either remember the flags using
the phrase "git dog", `d` for `--decorate`,
`o` for `--oneline`, `g` for `--graph` or
you can set an alias for the `git log` command:

```bash
$ git config --global alias.dog "log --decorate --oneline --graph"
```

This alias makes these two commands equivalent:

```bash
$ git dog
$ git log --decorate --oneline --graph
```

You can of course customise the log command
with other keywords and set more aliases for
different log views.
Some useful examples can be found on
The [GitHub Documentation for git log](https://git-scm.com/docs/git-log) has information on all the available flags.
Some useful examples of `git log` alias's and flags can be found on
[this Stackoverflow comment](https://stackoverflow.com/questions/1838873/visualizing-branch-topology-in-git/34467298#34467298).

:::

::: callout

### IDE Git History Extensions
Expand All @@ -127,14 +63,14 @@ If you use VSCode we recommend the [Git Graph extension](https://marketplace.vis

## Merge Options

When you opened your PRs you were given
When you open a PR you are given
three options for merging your feature
branch into `main`.
We will now explore how each merging method
affects the history of your repository.
In all the examples below we start with the same git history.

### Merge
## Merge

Starting with:

Expand Down Expand Up @@ -183,7 +119,7 @@ keeps all the individual commits that made
up your change so more accurately represents
the history of your repository.

### Squash and Merge
## Squash and Merge

Starting with:

Expand Down Expand Up @@ -226,7 +162,7 @@ Squashing in this case will make bug hunting harder.
Remember you should try and break work down into
small pieces so you avoid huge branches.

### Rebase
## Rebase

Starting with:

Expand Down Expand Up @@ -288,6 +224,6 @@ for your project.
branch into `main`.
- merge: creates a merge commit and results in a non-linear history unless you first rebase your feature branch.
- squash and merge: squashes all your feature branch commits into one merge commit on `main`. Your history is linear.
- rebase: re-writes your git history so that all the feature branch commits are now on `main`. Your history is linear.
- rebase: re-writes your git history so that all the feature branch commits are now on `main`. Your history is linear.

::::::::::::::::::::::::::::::::::::::::::::::::::
16 changes: 8 additions & 8 deletions instructors/instructor-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ the yellow challenge **Local Cleanup**.

Remember to take regular breaks.

### [History](../episodes/07-history.md)

Users will have covered using `git log` in the intro lesson.
Show learners what the history of the repository looks like now.
Then walk through the merge options, keep it short and snappy.
There are no learner exercises in this episode,
make sure you ask learners what questions they have at the end.

### [Forks](../episodes/05-forks.md)

You can choose here to either change everyone's permissions down
Expand All @@ -238,14 +246,6 @@ branches and created their feature branches).
They can bypass protections and do this while the first instructor is teaching.
This generates the citation file conflict the first instructor will point out.

### [History](../episodes/07-history.md)

Users will have covered using `git log` in the intro lesson.
Show learners what the history of the repository looks like now.
Then walk through the merge options, keep it short and snappy.
There are no learner exercises in this episode,
make sure you ask learners what questions they have at the end.

### [End](../episodes/End.md)

What questions do the learners still have?
Expand Down

0 comments on commit 7d4ed94

Please sign in to comment.