I have an existing Visual Studio project file (appsettings.json
) that contains sensitive data that I do not want to publish to GitHub.
A repository is not currently created but I would like to create one without including the appsettings.json
file.
I know that I can use the .gitignore
file to exclude files after the initial push, but at this point the sensitive file would already have been pushed.
Moving forward, I can create the repository from the start of the project, but how should this be handled for an existing project without a repository?
CodePudding user response:
I know that I can use the
.gitignore
file to exclude files after the initial push
Actually, you can use it before the initial push, even before the initial add to the index.
Simply create in VSCode a .gitignore
at the root folder of your project, with as a content:
/.vscode/appsettings.json
(assuming this setting file was created automatically in the .vscode/
folder of your VSCode workspace for this project)
Then add and commit: you won't see that file in your first commit, than you can then push.