I want to add an overrides.json
. That allows developers to make changes to a config object locally. I want it added to the repository in a default state but I want future changes on it to be ignored.
It seems like .gitignore
forces me to remove it from the branch before I can ignore it. I know about git update-index
but each developer would have to do this manually. To clarify, I do not want the file removed; I actually want the file to be added to repository but untracked after that.
I can't simply remove it because GET
requests to a missing file throws ugly error messages in the browser's javascript console.
In the Git Changes window, right-click any changed file that you want Git to ignore and choose Ignore this local item or Ignore this extension. Those menu options don't exist for tracked files.
Set “–assume-unchanged” to a path to exclude to check on git commit and it will exclude your file from git commit. You will need to use the git update-index and –assume-unchanged to exclude files from git commit.
Creating an ignore file To avoid having to ignore unwanted files manually, you can create a . gitignore file in the working directory of your project. Inside this file, you can specify simple patterns that Git will use to determine whether or not a file should be ignored.
The git add command will not add ignored files by default. If any ignored files were explicitly specified on the command line, git add will fail with a list of ignored files.
After adding the file you can ignore all further changes by doing:
git update-index --assume-unchanged path/to/file
If at some point you decide that you need to push more changes you can allow again changes by doing:
git update-index --no-assume-unchanged path/to/file
Instead of adding the files in the repo, why not ignore them and add them to a different location, eg. a setup directory. This way after cloning the repo, the developers will need to execute an init step that will copy the needed files in the proper location, where they are ignored.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With