Search code examples
gitreactjsgithubcreate-react-app

Git ignore public/index.html


Thanks for reading my question in advance.The Git always ignores the public/index.html file. I created a project by create-react-app and it works successfully.
But when I push it to Github, the public/index.html was lost. Take this project for example.
the .gitignore is:

# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
/node_modules

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

I tried to new another index.html and commit/push it again.But it shows nothing to commit. How can I fix this problem? The terminal looks like this:
enter image description here


Solution

  • The command to use whan a file is not added/committed is:

    git check-ignore -v -- public/index.html
    

    That will tell you if there is any gitignore/exclude/core.excludesfile file with an ignore rule.

    Typically, an IDE can add its own ignore rules in a global gitignore file.