If you've added a file with git add but haven't committed it yet, and you want to remove it from the next commit without deleting it from your working directory, use:
git restore --staged <file>
git restore --staged config.jsonThis removes config.json from the staging area so it won’t be part of the next commit, but it will remain on your filesystem If you don’t want to keep the file (neither in Git nor on disk), and you've already staged it (with git add), then you can
git rm <file>
git rm secrets.txt