0

I am currently developing a kind of small web-application which I would like to put on GitHub in a public repository. I want to do this to make it open source but I would also like to use the advantages of git while developing it. Now since I am using PHP and MySQL to develop it I sometimes have a line in my code where I create a new object of the class $PDO in which I also have to write my username and password for my MySQL database. Now I would like to know if there is a way to still upload my scripts to GitHub and to also use Git while keeping those lines private. Have a nice day.

2 Answers2

0

Place your credentials in a separate file and add this file to .gitignore

See https://git-scm.com/docs/gitignore

Maarten van Middelaar
  • 1,691
  • 10
  • 15
0

There is no way to only version control part of a file, however, you can only version control specific files using the .gitignore

For example file structure:

-- .gitignore
-- password.txt
-- script.py

And inside the .gitignore file:

password.txt

This will make is so git does not add the password file to github & you can safely store you information in it!

Aaron N. Brock
  • 4,276
  • 2
  • 25
  • 43