问题
I cloned a repository and edited exactly one file in it, tip.php
, and then added it using git add
. But when I next run git status
I get the following:
$ git status
On branch removeRatings
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: .htaccess
deleted: COPYRIGHT.txt
modified: tip.php
Even though neither .htaccess
or COPYRIGHT.txt
was deleted, as I can see them right in the directory. Anyone have a reason why this would happen? I'm running Git Bash on Windows 8.
回答1:
This message means that files (or file removals) were added to stage.
Run the following commands.
git add --all
git status
Now you should see whether they were moved/renamed or just deleted. I suppose that they were moved in some way, maybe by your IDE.
git reset .htaccess
git reset COPYRIGHT.txt
git status
Now the status should be clear and show only your tip.php
. But if you now see .htaccess
and COPYRIGHT.txt` in the untracked files, then these files have been changed since the last commit.
If you're sure that you didn't change or delete them and do not want to save changes:
git reset --hard .htaccess
git reset --hard COPYRIGHT.txt
This will reset these files to the state of last commit. Be careful and don't run git reset --hard
without an argument, as it would completely delete your uncommited changes.
来源:https://stackoverflow.com/questions/30806887/git-status-incorrectly-saying-files-are-deleted