简体   繁体   中英

git - trying to exclude certain files but want to add everything else

I am looking to add an entire website to a repository, but I want it to ignore several files.

So in my cloned folder I went to the exclude file and added the filename which is located in the root of the site.

Eg

/myrootfile.php

I then try git add * to add everything, however Im getting the following warning...

The following paths are ignored by one of your .gitignore files:
myrootfile.php
Use -f if you really want to add them.
fatal: no files added

I am wondering how should I still add everything else but simply ignore this file?

Thank you

The shell is expanding your glob pattern, so when you run

git add *

it is as though you had invoked

git add myrootfile.php this.php that.php the-other.html

Hence poor git's confusion because you say you want to ignore it but then explicitly add it.

In your site root, run the following instead

git add .

The dot refers to the current directory, into which git then descends recursively.

git add . worked, I am unsure why but this resolves the issue, after that git add * seems to work, so im assuming it adds the required .gitignore file.

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