James
James

Reputation: 400

How to ignore all changes files in wwwroot/js directory in .gitignore

as the title says. How do I ignore all files in wwwroot/js directory for my ASP.NET Core Application. I'm using TypeScript that automatically create js files in my wwwroot/js directory, so I don't want .js in my changes.

What I Already try in my .gitignore files.

wwwroot/js/
**/wwwroot/js
wwwroot/js/*
**/wwwroot/js/*
/SolutionFolder/WebFolder/wwwroot/js/*

And none of them is working.

Here's my project path:

Project
   SolutionFolder
      WebFolder
         wwwroot
            js
      Project.sln
   .gitattributes
   .gitignore

Any solution? Thank you before.

Upvotes: 0

Views: 2356

Answers (3)

GonzaH
GonzaH

Reputation: 357

In the .csproj file, inside the tag <PropertyGroup> </PropertyGroup> add <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>

Example

  <PropertyGroup>
    <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
  </PropertyGroup>

Then, delete all files from wwwroot/js and add that path in the .gitignore

Upvotes: 1

John Sari
John Sari

Reputation: 358

Like Geno Chen said, what do you mean by "none of them is working"? Have you tried to delete all files in from wwwroot/js? After that just commit the changes and try to rebuild the Solution again. and your all deleted files in wwwroot/js is back without including them in the changes again.

Also SolutionFolder/WebFolder/wwwroot/js/* is already correct. try just using this one in your .gitignore

Upvotes: 1

Geno Chen
Geno Chen

Reputation: 5214

What do you mean by "none of them is working"? I f you mean you are still seeing it in git tracking or so, you may need git filter-branch for deleting the directory from the git history.

Also, the correct path in .gitignore is SolutionFolder/WebFolder/wwwroot/js/*. However you have already use glob ** to cover it.

Upvotes: 1

Related Questions