Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git .gitignore to ignore only folder in root directory

Tags:

git

gitignore

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?

like image 861
Sagar Devkota Avatar asked Apr 22 '17 06:04

Sagar Devkota


People also ask

How do I ignore a folder in Gitignore?

If you want to maintain a folder and not the files inside it, just put a ". gitignore" file in the folder with "*" as the content. This file will make Git ignore all content from the repository.

Does .gitignore need to be a the root folder?

A . gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Generally, this is placed in the root folder of the repository, and that's what I recommend. However, you can put it in any folder in the repository and you can also have multiple .


1 Answers

Just add / before static/, should be like

  /static/  # ^ forward slash before the folder name signifies root dir 
like image 68
Mr. Alien Avatar answered Oct 24 '22 06:10

Mr. Alien