Git .gitignore to ignore only folder in root directory

GitGitignore

Git Problem Overview


Here is my .gitignore

static/

and I have installed git on the folder named project there is a folder named static and another folder called app and inside the app folder, there is another folder static. The above .gitignore ignore both static folders, That is not what I want.

What I want is to ignore the folder project/static/ not the folder project/app/static/ How can I do that?

Git Solutions


Solution 1 - Git

Just add / before static/, should be like

  /static/

# ^ forward slash before the folder name signifies root dir

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSagar DevkotaView Question on Stackoverflow
Solution 1 - GitMr. AlienView Answer on Stackoverflow