The files are THERE, git just tells me that they have been deleted from the repository. Could this be a Github problem?
I have navigated to my project folder that I haven't worked on in a couple of days, and like usual I run:
git status
However, instead of seeing 1 or 2 files, the status shows that all of my files have been deleted. Then, in "Untracked Files", it shows all of my files and directories in app root that need to be added.
I don't understand what has happened, but I am very worried that any work I did since the last commit is gone.
I opened the git log up with git k
, and at very the top I see:
Local changes checked in to index but not committed.
Right below that I see:
master remotes/origins/master
Note: This project goes against a github database.
Here is the output from the git status
command:
➜ mcp5_mobile git:(master) ✗ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: .gitignore
deleted: .rspec
deleted: Gemfile
deleted: README
deleted: README.md
deleted: Rakefile
deleted: app/assets/images/MSDS_icon_rgb.jpg
deleted: app/assets/images/MSDS_icon_rgb.png
deleted: app/assets/images/addtocart.gif
<Continues to list every single file in the app. Over 1,100 files.>
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
.rspec
Gemfile
README
README.md
Rakefile
app/
autotest/
colorpicker.css
config.ru
config/
db/
deploy/
doc/
eye.js
features/
layout.css
lib/
public/
sample.xml
script/
spec/
termios/
test/
vendor/
This strongly suggests that you (or something you invoked indirectly) deleted or at least renamed .git/index
:1
$ ls
LICENSE.txt x.txt
$ git status
On branch master
nothing to commit, working directory clean
$ mv .git/index .git/xindex
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: LICENSE.txt
deleted: x.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
LICENSE.txt
x.txt
$ mv .git/xindex .git/index
$ git status
On branch master
nothing to commit, working directory clean
In the above, I recovered by putting the index
file back, but if it's really gone you can rebuild it from the HEAD
commit using git reset
's --mixed
(default) mode:
$ rm .git/index
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: LICENSE.txt
deleted: x.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
LICENSE.txt
x.txt
$ git reset -- .
$ git status
On branch master
nothing to commit, working directory clean
[Aside: you don't need the -- .
as those are also the default. This was more to emphasize that we're resetting every path inside .
that is in the HEAD
commit. Of course I'm using the default-to-HEAD
-commit action by not specifying HEAD
explicitly either...]
1Alternatively, perhaps something you did set the environment variable GIT_INDEX
to point somewhere odd. Git uses .git/index
when GIT_INDEX
is not set, so if something has set it, that would override the default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With