Exclude files from git without adding to .gitignore

Brandon C. Roberts,git

Often times, I have the need to exclude files from being tracked by git without adding them to the .gitignore file. This is especially useful when working on a project with other developers and you don’t want to add your own personal configuration files to the .gitignore file. To do so, in the repository, open the .git/info/exclude file and add the files you want to exclude. For example, if you want to exclude a file named .github/copilot-instructions.md, add the following line to the file:

.github/copilot-instructions.md

Documentation: gitignore documentation

2025 © Brandon C. Roberts.RSS