GIT · History · 5 min

Give the last commit a useful name

Repair a local commit message while preserving its contents.

Not completed

Your task

Replace the latest message wip with exactly: Document deployment checks. Keep its tree and parent unchanged, and do not add a third commit.

What you’re aiming for

  • The latest subject is Document deployment checks.
  • The two-commit history retains the original first commit.
  • The saved file contents are unchanged.

1. Prepare your practice folder

Use Git 2.28 or newer. The setup commands below use a Bash-compatible shell: Git Bash on Windows, or Bash on Linux/macOS.

Create a new, empty folder for this exercise. If that name already exists, choose another new name. Continue only after you’re inside the new folder.

NEW PRACTICE FOLDER
mkdir opsrung-git-fix-commit-message && cd opsrung-git-fix-commit-message

Run these setup commands in that folder:

SETUP — RUN ONCE
git init --initial-branch=main
git config --local user.name 'Practice Learner'
git config --local user.email 'practice@example.invalid'
printf 'Initial checks.\n' > notes.txt
git add notes.txt
git commit -m 'Initial notes'
printf 'Run tests before deployment.\n' > notes.txt
git add notes.txt
git commit -m wip
Only if your personal Git settings interfere

You can normally skip this. If a commit asks for a signing key, runs a custom hook, or changes line endings unexpectedly, these repository-local overrides keep this disposable exercise independent of those settings.

OPTIONAL REPOSITORY OVERRIDES
git config --local commit.gpgsign false
git config --local core.autocrlf false
git config --local core.hooksPath .git/practice-no-hooks

Retry the failed command afterward. These settings apply only inside this practice repository.

2. Try the task

Work toward the goal above. Start by inspecting the files or resources, then use a hint if you need one.

Hint 1

git log --oneline shows the current message.

Hint 2

This is unpublished practice history. Amending replaces the latest commit.

Hint 3

Use git commit --amend -m with the requested message.

3. Review your result

Use these commands to look at your result and compare it with the goals. The website does not run or verify them.

REVIEW IN YOUR TERMINAL
git log --oneline
git show HEAD:notes.txt
git status

What you should see

  • The latest subject in git log --oneline is Document deployment checks.
  • There are still two commits, with Initial notes below the amended commit.
  • git show HEAD:notes.txt prints Run tests before deployment. and git status is clean.

If your result differs: Creating a third commit does not rename the previous one. Amend the latest practice commit while preserving its contents.

Compare with one possible solution
ONE POSSIBLE SOLUTION
git commit --amend -m "Document deployment checks"

Other approaches are fine if you reach the same goal. Opening this solution does not mark the exercise complete.

Finished this exercise?

You decide when you’re done. Your choice is saved in this browser, and you can change it later.