skargor
skargor

Reputation: 1031

git ignore directory except for specified

I want to ignore entire public_html/ directory except one file inside

I give .gitignore as below:

public_html/*
!public_html/config/config.php

However, when I run git status , I can not find config.php has been included.

Upvotes: 9

Views: 3570

Answers (2)

manojlds
manojlds

Reputation: 301587

First commit / add public_html/config/config.php and then add public_html to the gitignore.

Upvotes: 2

Timofey Stolbov
Timofey Stolbov

Reputation: 4631

Change .gitignore to

public_html/*

And force adding config.php into index.

git add -f public_html/config/config.php

Upvotes: 10

Related Questions