Skip to content

Instantly share code, notes, and snippets.

@aloisdg
Created June 3, 2016 02:01
Show Gist options
  • Save aloisdg/38a6a09b614d8455b6d1e685a77a5eba to your computer and use it in GitHub Desktop.
Save aloisdg/38a6a09b614d8455b6d1e685a77a5eba to your computer and use it in GitHub Desktop.

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.

source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment