问题
I've gotten myself into a pickle.
I have .dat files on-disk, and through a twisted and obviously incorrect git procedural sequence, git thinks I've deleted the files. The state of the files is as I want (present), but git status still thinks they're deleted.
I've tried doing "git checkout -- file", "git add file", "git checkout -- file" and nothing seems to touch the status. I don't want to use "git rm" because I really don't want the files removed from either the disk or the cache...the repo just seems confused.
How do I get the repo back into sanity?
Here's a listing:
$ git status
On branch master
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: SHAP5-2.2-20140304T1200.CO2.dat
deleted: SHAP5-2.2-20140304T1200.H2O.dat
deleted: SHAP5-2.2-20140304T1300.CO2.dat
deleted: SHAP5-2.2-20140304T2300.CO2.dat
deleted: SHAP5-2.2-20140304T2300.H2O.dat
no changes added to commit (use "git add" and/or "git commit -a")
回答1:
First you can use git reset -- <file> to unstage the deleted files:
git reset -- SHAP5-2.2-20140304T1200.CO2.dat
Then do git checkout -- <file> to restore the deleted files into your working directory from the index:
git checkout -- SHAP5-2.2-20140304T1200.CO2.dat
Repeat this procedure for all 5 files and you should be good to go.
来源:https://stackoverflow.com/questions/30496258/git-shows-delete-in-status-but-theyre-not