Can't delete a file in Linux from corrupted git repository with the message "the file doesn't exist"

Marco Gasi
Marco Gasi used Ask the Experts™
on
Hi everybody.
For some reason I ignore, a avi file has been copied or inserted in my local git repository and renamed as it be  an object. In Nautilus its icon shows the movie preview and if I double-click on it, I can watch the movie.
Now I can't commit my files so, once I have understood what happened, I have tried to delete it opening Nautilus as root or using sudo rm -i and the object name as it appears in Nautilus and in git error, but I get an error telling the file or the directory doesn't exist.

I can't just clone the repositories from BitBucket because it is not updated: I got this error some days ago but I had to go on with the work, so now I have a lot of changes not committed nor pushed.

I would like just to delete the movie from the repo but I don't know how to do it.

Someone can tell me what I have to do? btw, I'm new to Git and generally speaking not so confident with version control commands )

Thank you so much for any help.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
nociSoftware Engineer
Distinguished Expert 2018

Commented:
the next might help:

find /path/to/my/gitrepo  -type f -print0 | xargs file 

Open in new window


The will walk the tree of files and report on file type..., one of the files should be an .avi file ....
Marco GasiFreelancer
Top Expert 2010

Author

Commented:
Hello noci, thank you for your answer.
In the command prompt from the same directory where the corrupted object/avi file is I run your command
find -type f -print0 | xargs file

Open in new window

and got this:
xargs: WARNING: a NUL character occurred in the input.  It cannot be passed through in the argument list.  Did you mean to use the --null option?
./0a3ee3fdfc564c64dda785c719b9f54c3f7585: zlib compressed data

Open in new window

nociSoftware Engineer
Distinguished Expert 2018

Commented:
forgot to type the -0 with xargs... this should work...

find -type f -print0 | xargs -0 file

Open in new window

Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Marco GasiFreelancer
Top Expert 2010

Author

Commented:
Sorry for the delay, I had missed your comment )
Okay, your command works fine: this is the output:
./0a3ee3fdfc564c64dda785c719b9f54c3f7585: zlib compressed data
./0abd8c64c97cd7780df813f3b706044886451b: RIFF (little-endian) data, AVI, 720 x 400, 25.00 fps, video: DivX 5, audio: MPEG-1 Layer 3 (stereo, 48000 Hz)
./12571d78a49fdda9458d4a479fd5752a9ac2a4: zlib compressed data
./32587279f7909677e47af685c7dc73f722a3c9: zlib compressed data
./34b9a80944b1c813f8efa664cefc97e63dc65e: zlib compressed data
./4047b191a6bec035579365a497561ae919cff9: zlib compressed data
./46291f78eff20ef99207e8ca96b804b6cfe92a: zlib compressed data
./50e6afb1e2947d427d9e325a17f089de94f4a7: zlib compressed data
./53118a782f95cb0cc3207e2e0de51b6a9cda1a: zlib compressed data
./8911a13e05ccda77f39ab32e9bb4f164e2cbd6: zlib compressed data
./8cd786ec697b49750939c84bead9eb560665a4: zlib compressed data
./950d147fac7b6ab0cf6a99f85379b0295cfae9: zlib compressed data
./ab8ca25c5ee4d711b7d9c456ee60c62f963a03: zlib compressed data
./e841763c2f8d8744ce82226c78719e6728261b: zlib compressed data
./fd54f4d05e124e80db9264c3c858a46b6b49f9: zlib compressed data

Open in new window

But it doesn't solve the problem: I could see the file even with 'ls' command or in any file manager: the problem is that even if it definitely exists, when I try to delete it I get the error message that it doesn't exist. Or am I missing something?
Marco GasiFreelancer
Top Expert 2010

Author

Commented:
I have tried this:
find . -maxdepth 1 -name '*0abd8c64c97cd7780df813f3b706044886451b*' -delete

Open in new window

and the output has been:
find: cannot delete ‘./0abd8c64c97cd7780df813f3b706044886451b’: No such file or directory

Open in new window

I tried this:
rm -i 0abd8c64c97cd7780df813f3b706044886451b

Open in new window

and the output has been
rm: remove regular file '0abd8c64c97cd7780df813f3b706044886451b'? y
rm: cannot remove '0abd8c64c97cd7780df813f3b706044886451b': No such file or directory

Open in new window

nociSoftware Engineer
Distinguished Expert 2018

Commented:
i would have expected output lines like

.../objects/xx/yyzzaabbcc...                    some type of file...

In the directory you found it try
ls -l *

Open in new window

are there any "non printable characters" in a filename
Marco GasiFreelancer
Top Expert 2010

Author

Commented:
Output:
ls -l *
-rwxrwxrwx 1 marco marco     33565 May  5 13:07 0a3ee3fdfc564c64dda785c719b9f54c3f7585
-rwxrwxrwx 1 marco marco 367310848 Aug 30  2012 0abd8c64c97cd7780df813f3b706044886451b 
-rwxrwxrwx 1 marco marco      3702 May  5 13:06 12571d78a49fdda9458d4a479fd5752a9ac2a4
-rwxrwxrwx 1 marco marco      3079 May  5 13:07 32587279f7909677e47af685c7dc73f722a3c9
-rwxrwxrwx 1 marco marco       173 May  5 13:07 34b9a80944b1c813f8efa664cefc97e63dc65e
-rwxrwxrwx 1 marco marco      3699 May  5 13:08 4047b191a6bec035579365a497561ae919cff9
-rwxrwxrwx 1 marco marco     17061 May  5 13:07 46291f78eff20ef99207e8ca96b804b6cfe92a
-rwxrwxrwx 1 marco marco       237 May  5 13:07 50e6afb1e2947d427d9e325a17f089de94f4a7
-rwxrwxrwx 1 marco marco      1116 May  5 13:06 53118a782f95cb0cc3207e2e0de51b6a9cda1a
-rwxrwxrwx 1 marco marco     36226 May  5 13:07 8911a13e05ccda77f39ab32e9bb4f164e2cbd6
-rwxrwxrwx 1 marco marco      1385 May  5 13:07 8cd786ec697b49750939c84bead9eb560665a4
-rwxrwxrwx 1 marco marco       279 May 11 13:04 950d147fac7b6ab0cf6a99f85379b0295cfae9
-rwxrwxrwx 1 marco marco      2836 May  5 13:07 ab8ca25c5ee4d711b7d9c456ee60c62f963a03
-rwxrwxrwx 1 marco marco      1103 May  5 13:07 e841763c2f8d8744ce82226c78719e6728261b
-rwxrwxrwx 1 marco marco      1098 May  5 13:07 fd54f4d05e124e80db9264c3c858a46b6b49f9

Open in new window

The second is the file I want to delete
Software Engineer
Distinguished Expert 2018
Commented:
afaict from the directory listing it is a normal file, no ACL, no special device, no multple links...
( i forgot to ask about selinux...)
what does ls -Z show?

can it be moved? (try with completion...)
mv 0ab<tab> ~/bad-movie.avi

( <tab> meaning pressing the tab key, after that name is taken from the directory listing )
Marco GasiFreelancer
Top Expert 2010

Author

Commented:
ls -Z
? 0a3ee3fdfc564c64dda785c719b9f54c3f7585  ? 53118a782f95cb0cc3207e2e0de51b6a9cda1a
? 0abd8c64c97cd7780df813f3b706044886451b  ? 8911a13e05ccda77f39ab32e9bb4f164e2cbd6
? 12571d78a49fdda9458d4a479fd5752a9ac2a4  ? 8cd786ec697b49750939c84bead9eb560665a4
? 32587279f7909677e47af685c7dc73f722a3c9  ? 950d147fac7b6ab0cf6a99f85379b0295cfae9
? 34b9a80944b1c813f8efa664cefc97e63dc65e  ? ab8ca25c5ee4d711b7d9c456ee60c62f963a03
? 4047b191a6bec035579365a497561ae919cff9  ? e841763c2f8d8744ce82226c78719e6728261b
? 46291f78eff20ef99207e8ca96b804b6cfe92a  ? fd54f4d05e124e80db9264c3c858a46b6b49f9
? 50e6afb1e2947d427d9e325a17f089de94f4a7

Open in new window


And:
 mv 0abd8c64c97cd7780df813f3b706044886451b ~/bad-movie.avi
mv: cannot remove '0abd8c64c97cd7780df813f3b706044886451b': No such file or directory

Open in new window


Maybe using a live USB I can do it?
nociSoftware Engineer
Distinguished Expert 2018

Commented:
I think you need an fsck of that disk, so yes an live USB / ISO may be able to get around this.
Is there possibly a "hidden" space as part of the file name?

This will likely not return a result.
ls -l 0abd8c64c97cd7780df813f3b706044886451b

try
ls -l 0abd8c64c97cd7780df813f3b706044886451b\  <-- There's a space after the backslash.
or
ls -l "0abd8c64c97cd7780df813f3b706044886451b "

If those work, then you can remove the file.
Marco GasiFreelancer
Top Expert 2010

Author

Commented:
@serialband, thank you to you too for your answer.
The point is now this: yesterday I have tried to access from a Live distro and I got the same message that the file didn't exist. Then I logged in Windows - I forgot to say that the project files and the repository are in an external hard drive in order to allow me to access them from both Linux and Windows. And using the Explorer I have seen that the file... didn't exist! Coming back to Linux, the file was no more there, so I thought I could finally commit my changes. But I have got another error about another corrupted object!!
So I think to open a new question because I suspect there is something I'm missing about share one git repo between WIndows and Linux. I'll post here the link to my new question.
Thank you both )
Marco GasiFreelancer
Top Expert 2010

Author

Commented:
Marco GasiFreelancer
Top Expert 2010

Author

Commented:
Thank you both. I have posted a link to a new question about the same issue from a different perspective )

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial