-->

files in the git repo are both deleted and untrack

2019-07-23 16:18发布

问题:

All the (hundreds of) files in my repo now show up as untracked and deleted though I can't figure out what's going on?

ls shows the files are in the directory

but git status . in the directory has the files as deleted and untracked. I haven't touched any of these files in a couple months. Also the website the files are for is not working now...

回答1:

The situation may have been caused by the IDE that you are working with. The possible scenario, AFAIK may have been this :

1- You have deleted the four files ( dashicons.eot, .svg, .... ), from your IDE, which probably has a git plugin to track the changed files.

2- After some time, you changed those file and added them again, but either the IDE git plugin hasn't synced yet or you have restored them from outside of the IDE.

To see what a final valid result for git tracking in these files would be, I recommend :

git reset <file-name>

to unstage changes to be committed for <file-name> or just simply

git reset

which will unstage all file that were staged with git add, either in the terminal or by the IDE plugin.

Then,

git status

I assume you should now see that your files (dashicons) are modified, not deleted

Now you can add them again and commit your modifications and no deletion will be applied to your repository, both local and remote.



回答2:

The git status shows that you have not committed the changes after deleting the files(dashicons.eot, dashicons.svg, dashicons.ttf and dashicons.woff). Also, it shows these files are untracked.

-

"I haven't touched any of these files in a couple months."

Since you are not sure about the changes you did, we recommend you to clone the project again in another directory and work with the new directory.