Let’s assume you have a config file with API Key, you want to add this file in your Github repository but not the API Key.
There is many ways to achieve this, but this my method.
First, replace your API KEY you want to hide in your file,
If the file is not yet in the repository, run
Git add <file> Git commit -a
else
Git commit -a
Now you can edit this file and put back your API Key
For ignore the changes in the next commits, use
git update-index --assume-unchanged <file>
It's done, You can now use your API key locally and share your repository without security issue.
If you want to undo this command, run
git update-index --no-assume-unchanged <file>
Comments
Write comments