GIT · History · 10 min

Set dates on a disposable commit

Understand author and committer timestamps in local history.

Not completed

Your task

Set both timestamps on the latest practice commit to 2020-05-10T09:30:00+00:00. Preserve the tree, subject, and parent. Use this only in the disposable exercise.

What you’re aiming for

  • Author and committer dates match the requested instant.
  • The contents and two-commit history are preserved.

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-set-practice-date && cd opsrung-git-set-practice-date

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 '%s\n' 'A disposable OpsRung practice repository.' > README.txt
git add -- README.txt
git commit -m 'Start practice'
printf '%s\n' 'A synthetic historical entry.' > schedule.txt
git add -- schedule.txt
git commit -m 'Record practice schedule'
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

Author time and committer time are separate metadata.

Hint 2

--date changes the author date; GIT_COMMITTER_DATE controls the committer date.

Hint 3

Supply both when amending the practice commit.

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 -1 --format=fuller
git status

What you should see

  • Author and committer dates match the requested instant.
  • The contents and two-commit history are preserved.
  • UTC may be displayed as Z or +00:00; both represent the same instant.

If your result differs: Work only in this exercise’s repository. Compare the branch, files, and history with every goal before marking complete.

Compare with one possible solution
ONE POSSIBLE SOLUTION — BASH
GIT_COMMITTER_DATE='2020-05-10T09:30:00+00:00' git commit --amend --no-edit --date='2020-05-10T09:30:00+00:00'

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.