If you’re an end user, not a build tool, you’d rather want to place that in .git/info/exclude inside the repo. It’s effectively another gitignore file, which won’t be committed.
But if you do need something like this for a build tool, then yeah, you can create a file /test/.gitignore with these contents:
real-person-first-last.json
.gitignore
Then running git add . just adds /test/fake-person-first-last.json.
Both /test/.gitignore and /test/real-person-first-last.json would be ignored right away.
If you’re an end user, not a build tool, you’d rather want to place that in
.git/info/excludeinside the repo. It’s effectively another gitignore file, which won’t be committed.But if you do need something like this for a build tool, then yeah, you can create a file
/test/.gitignorewith these contents:real-person-first-last.json .gitignoreThen running
git add .just adds/test/fake-person-first-last.json.Both
/test/.gitignoreand/test/real-person-first-last.jsonwould be ignored right away.