Hide API Key in Github repository

This entry was posted in Git / Github on 2019-02-02 by Eddy
347 Git

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

No results found.

Write comments

Math, for example, 45-12 = 33

Subscribe Now

You will receive a notification to each new article.

Tag Cloud

  • Composer
  • Yii2
  • OpenGraph
  • Helper
  • Wordpress
  • PhpMyAdmin
  • .htaccess
  • Config
  • Production
  • Git
  • Api
  • Mailchimp
  • Github
  • Vue.js