0

I would like visual studio to ignore "appsettings.json" from being uploaded to github repository.

I have tried putting the file name in .gitignore but visual studio 2017 still record it as a change and push it to the repository

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

appsettings.json

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

I expect the "appsettings.json" to be ignored when pushing the changes to the repository.

mohammed alani
  • 336
  • 4
  • 18
  • PM> git rm --cached appsettings.json git : fatal: pathspec 'appsettings.json' did not match any files At line:1 char:1 + git rm --cached appsettings.json + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (fatal: pathspec...match any files:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError – mohammed alani Mar 25 '19 at 20:52

1 Answers1

0

Same issue as here: .gitignore isn't ignoring files in certain folder

git rm --cached appsettings.json
EncryptedWatermelon
  • 4,788
  • 1
  • 12
  • 28
  • It can be a little more complicated than just removing from the next revision.... For example.... what will happen if you do this, commit, checkout the previous revision and then go back to the tip of the branch? Goodbye appsettings.json. Not really good bye... you can always get it back from git, of course.. but you get the idea, right? if you want the file to be _gone_ from the history of the branch, you would need to rewrite history. – eftshift0 Mar 25 '19 at 20:50
  • True... if you want it permanently gone... git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch path_to_file" HEAD – EncryptedWatermelon Mar 25 '19 at 20:55