A
A
Aricus2019-11-14 12:04:35
git
Aricus, 2019-11-14 12:04:35

What is my mistake when using gitignore?

I need to exclude the config/db.php file from the future repositories of the project, which already has pushes.
I added a line to .gitignore (in the root of the project). However, adding the
db.php
file is not excluded (the project folder path is replaced by ...):

...>git reset HEAD config/db.php
Unstaged changes after reset:
M config/db.php
...>git status
On branch HW4
Changes to be committed:
(use "git restore --staged ..." to unstage)
modified: .gitignore
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git restore ..." to discard changes in working directory)
modified: config/db. php
...>git add :/
warning: LF will be replaced by CRLF in config/db.php.
The file will have its original line endings in your working directory
...>git status
On branch HW4
Changes to be committed:
(use "git restore --staged ..." to unstage)
modified: .gitignore
modified: config/db.php

What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2019-11-14
@Aricus

Delete the file from the git cache:
git rm --cached config/db.php

V
Vladislav Lyskov, 2019-11-14
@Vlatqa

because you need to specify not only the file, but also the path to it, i.e. /config/db.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question