>_ IzzyLab

Hands-on task

This task is step 5 of the course “Everyday Git”

Add a forgotten file to the last commit

easy~3 min

In the /root/repo repository, the last commit add app includes only app.py, but an uncommitted file config.yml was left next to it — someone forgot to add it. Include config.yml in that same last commit, without creating a new one: after the fix, the history should still contain two commits, and HEAD should include both app.py and config.yml.

What you'll practise:
  • git commit --amend
  • index
  • git add
  • editing the last commit
  • --no-edit

Topic breakdown

The last commit in git is not set in stone: it can be replaced with a new one that absorbs the current state of the index — that's what git commit --amend does. Technically a different commit is created with the same parent, and the old tip is discarded, so the history doesn't grow in length. The typical scenario is adding a forgotten file or fixing a message without breeding extra "fix typo" commits.

What's checked

  1. config.yml is in the last commit
  2. app.py is still there
  3. no new commit was created

What it looks like