简体   繁体   中英

Git ignoring a file but not ones with names

In my .gitignore file I want to ignore a file just called .env but not files that have something.env :

I have tried this:

.env
!*.env

But it does not work

Just add .env in your .gitignore file

.gitignore

.env

Why can't you simply ignore .env . Thus your .gitignore reads:

.env

(only one line)

It will not ignore anything with the .env extension.

Example (console):

$ echo 'foo' > .env
$ echo 'foobar' > foo.env
$ git add .; git commit -am "foobar"
[master 49d6a00] foobar
 2 files changed, 2 insertions(+), 2 deletions(-)
 create mode 100644 foo.env

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM