Keep a generated file locally while stopping tracking

A generated file named debug.log is already tracked and committed. Your working tree and staging area have no pending changes. You want future commits to omit this file while keeping its local copy on disk. Complete the procedure using the long command option and the standard project ignore filename.

  • Run git rm -- debug.log from the project root.
  • Add a line containing /debug.log to the project-root file named .
  • Stage that ignore file and make an ordinary commit containing both changes.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Git Questions: