S
S
Svyatoslav Khusamov2017-03-14 09:44:04
git
Svyatoslav Khusamov, 2017-03-14 09:44:04

How to specify a specific file in .gitignore?

I have three files on the disk in their directories:

./modules/module1/package.json
./package.json
./.gitignore

The content of the .gitignore file is:
/package.json
I thought that specifying a file like this (with a leading slash) would ignore the file at the root of my directory. But it turned out not.
Here are the results of the status command:
./ $ git status
On branch master
Initial commit
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        .gitignore
        modules/

./modules $ git status
On branch master
Initial commit
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        ../.gitignore
        ./

The last status shows that the ./modules/module1/package.json file is also ignored.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lynn "Coffee Man", 2017-03-14
@khusamov

Actually, you specified everything correctly, you just check
https://git-scm.com/docs/gitignore incorrectly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question