9

Im new on GitHub, and google didnt give me an answer simple enough for me to understand, so here i go.

How do i commit to GitHub and keep my files up to date, but without committing my password/oauth tokens?
Does one remove the line before committing, or what are you supposed to do?

Im using IntelliJ, dark theme

Comments
  • 7
    Use the env variables, luke.
  • 2
    Store them in a file and dont commit the file
  • 2
    What these guys said, have a file that sits outside your project (usually env.ext) and reference it from your codebase do not add it to your repo.

    Each environment should have its own version of the file (dev, sandbox’s, uat, production, ect) with usually different
    Passwords and tokens suitable for that environment.
  • 4
    And if you want to be nice add a file to the repo describing what should be in the file you don't add to the repo
  • 3
    I would suggest you to store passwords in one file and import them where ever needed. Then create/edit ".gitignore" file and ignore the password file (git won't track that file -> it doesn't go to github). After that you can create a password template file.

    Like if you had env.js file where is all the passwords you need, add it to .gitignore and create env-template.js where you remove your passwords. You might add comments to the file like:
    // put your db password here
    ...
    // put your db url/host here
    ...
    Etc.

    Note though, if git is already tracking the file before adding it to .gitignore you need to do some extra googling.
  • 2
    Check the concept of "gitignore". Read up.
  • 1
    @okkimus @jspreddy
    Sounds like what i was looking for. Thanks :)
  • 1
    .gitignore
  • 0
    @dextel2 already mentioned, but thanks anyway :)
  • 1
    As already stated...use env variables
  • 0
    @oxmox urgh i guess ill research both env variables and gitignore now.. XD
Add Comment