0

This is a very basic question probably, but I cannot figure out how to use .gitignore to ignore a file during commits.

I am creating a Twitterbot in Node.js and have a config.js file with all my API keys. That's all I want to hide.

Do I just make a file called ".gitignore" and type out the name of the file (in this case, "config.js") and save it in my repo?

I'm a total newbie so thanks for any and all help!

2
  • 1
    Yes, you should try that... Commented Oct 13, 2015 at 17:12
  • git-scm.com/docs/gitignore Commented Oct 13, 2015 at 17:20

1 Answer 1

2

Yup, that's exactly what you do.

--MyDirectory
----.gitignore
----myconfig.js
----MyFolder1

Then create a .gitignore file and within it, just write

myconfig.js

Sign up to request clarification or add additional context in comments.

1 Comment

So what happens when you want to make a change to the configuration file and commit that? This suggests you remove the myconfig.js from .gitignore then commit then change .gitignore back to original and commit again?.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.