Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
324 views
in Technique[技术] by (71.8m points)

git - How do I not commit my config.php file(completely ignore it, neither download or upload it) to Github when using VSCode?

I have a config.php file on Github, I however have a different config.php file on my PC, how can I make Github completely ignore the file and make it both not download and upload it when I make a new commit?

I am using VSCode.

It is really annoying when it uploads the password of the config.php file to my private repo, is there a solution to that or should I just remove the config.php file from the folder when I want to make a new commit?

question from:https://stackoverflow.com/questions/65867266/how-do-i-not-commit-my-config-php-filecompletely-ignore-it-neither-download-or

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Add the file to your .gitignore file. Generally speaking, files that contain password or sensitive config information should be stored separately from your main git repository, for both security and so different workstations don't override each other.

For details, see the docs on gitignore.

Since the file was previously in the repository, run git rm -r --cached config.php to stop tracking it. Note that this file will still be present in past commits, so from a security perspective, if there is any sensitive information, you may want to consider changing passwords, etc.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...