I have a file project/data/data.csv
where project/
is the parent project and data/
is a submodule. Inside of project/data/
I run
git checkout origin/master data.csv
To which git replies:
error: pathspec 'data.csv' did not match any file(s) known to git.
When I go to master on gitlab however, the file is very much there.
I have tried doing git reset, git fetch and git pull, none of which have fixed the issue.
Something that happened before git got crazy, was that I got a corrupted tree object. To fix this I had to remove all such objects and then do a git fetch and a git pull.
This led to the data submodule reporting a dirty object, which I fixed by deleting the .git file and doing a git pull.
After which I seemed to be able to pull and push with no issue, so i am not sure if it is related.
Any suggestions on how to get git to track the file again?
If you already had the corruption and ended up deleting .git you already tried the hard reset (assuming you already tried git reset origin/master
and are not worried about losing any files. If that is the case try
git clone <repo>
and this should reinitialize your repo with the right files