EasyEnv
Git
BeginnerLesson 12 of 1325 min · hands-on

Hooks

Part of the Git course

Every team has a rule that everyone agrees with and everyone forgets. Run the formatter before committing. Do not commit the debugging print statement you added at 2am. Do not commit a file with your password in it. These rules get written in a wiki page nobody reads, and then somebody breaks one, and code review turns into a game of spotting the thing a machine could have spotted instantly.

A hook is a script that Git runs automatically at a specific moment in your workflow, such as just before a commit is recorded or just before a push leaves your machine. Think of it as a spellchecker for your commits: not a person nagging you, just a small automatic check that happens at exactly the moment it is useful, and that can stop you before the mistake becomes permanent. ...

Want to learn Git Hooks in a real environment?

Click below, get a fresh Linux box with Git ready to go, and work through Hooks hands-on with an AI tutor that knows your code.

Start this lessonHooks

What you'll learn

  • Client-side hooks
  • .git/hooks
  • Pre-commit
  • Shell hook example
  • Pre-commit framework

Read this lesson in your language

All lessons in this course

13 lessons
  1. 1Init and Your First Commit25 min
  2. 2Status, Diff, and Log25 min
  3. 3Branches and Merging30 min
  4. 4Resolving Merge Conflicts30 min
  5. 5Remotes: Push, Pull, Fetch30 min
  6. 6Stash and Cherry-pick25 min
  7. 7Rebasing30 min
  8. 8Interactive Rebase and Squashing30 min
  9. 9Tags and Releases20 min
  10. 10Branching Workflows20 min
  11. 11Recovering Lost Work25 min
  12. 12Hooks25 min
  13. 13Capstone: A Full Pull Request Flow40 min

Explore other courses

Hooks - Git (English) | Engineering Courses