This is a method to use .gitignore file and prevent the specified file from being uploaded to git hub.
I am creating an automatic trading system for bitcoin with ruby. However, uploading bitflyer's API_KEY to git hub is bad for security. After a lot of research, I found that the .gitignore file can handle it, so I'll record it.
I knew that ruby on rails could be out of the jurisdiction of git hub with environment variables, but this time it's a different method.
The procedure is roughly like this.
1 Create a .gitignore file directly under the application 2 Check the status with git status 3 Describe the files you want to exclude in the .gitignore file
Create a ".gitignore" file directly under the application. It is misunderstood as an extension and a warning is displayed before saving, but it seems that you should save it with ".gitignore.". Along with that, create key.rb that describes the API_KEY of bitflyer.
git status is like checking for uncommitted files. (I'm sorry if I made a mistake) Then you can see the two files you just created. If you push this to the repository as it is, API_KEY will be published, so I would like to hide "key.rb".
$ git status
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
key.rb
nothing added to commit but untracked files present (use "git add" to track)
If you write the key.rb file written by API_KEY in .gitignore, it will be successfully excluded from git hub.
key.rb
API_KEY = "Here is the key"
API_SECRET ="secret key writes"
.gitignore.
key.rb
Recommended Posts