I improve @Jaex's idea a little bit. My problem with his solution is the error thrown by the solution explorer. It is not very clean.
So you have a file Client.cs
with your class as partial
:
public partial class Client {
// your awesome code comes here
}
In another file ClientKeys.cs
with your class as partial
, you will add your keys:
public partial class Client {
private const string SecretKey = "WRITE_HERE_YOUR_API_Key";
}
Now, we won't ask git to ignore this file. Lets commit and push this:
git add ./ClientKeys.cs
git commit -m "Create a safety hideout for my keys"
git push origin master
Finally, we are going to ask him to ignore any update on this file:
git update-index --assume-unchanged ./ClientKeys.cs
Now you can come back to your code and replace WRITE_HERE_YOUR_API_Key
with your own private api key. This modification wont be follow by Git, so you can commit/push freely. Your solution explorer will stay warning free.
You can see my use of this implementation here.