Block Commits with a pre-commit Hook

medium 20 XP ~9 minHands-on lab Pro

Developers in /home/student/repos/inventory-api mark temporary debug code with DO NOT COMMIT, and sometimes commit it anyway.

Task

Install a pre-commit hook in this repository that:

  • refuses the commit when the staged version of any file being committed contains DO NOT COMMIT, printing pre-commit: remove DO NOT COMMIT from FILE to stderr (one line per such file)
  • allows the commit otherwise
  • looks only at what is being committed: a marker that exists only in unstaged edits, or in files not part of the commit, does not block it

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

TerminalNot started

Your machine is ready to start

Create a free account to open a machine and get graded.