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

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.
LVL 32
Marco GasiFreelancerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nociSoftware EngineerCommented:
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 ....
0
Marco GasiFreelancerAuthor 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

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

find -type f -print0 | xargs -0 file

Open in new window

0
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

Marco GasiFreelancerAuthor 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?
0
Marco GasiFreelancerAuthor 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

0
nociSoftware EngineerCommented:
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
0
Marco GasiFreelancerAuthor 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
0
nociSoftware EngineerCommented:
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 )
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Marco GasiFreelancerAuthor 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?
0
nociSoftware EngineerCommented:
I think you need an fsck of that disk, so yes an live USB / ISO may be able to get around this.
0
serialbandCommented:
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.
0
Marco GasiFreelancerAuthor 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 )
0
Marco GasiFreelancerAuthor Commented:
0
Marco GasiFreelancerAuthor Commented:
Thank you both. I have posted a link to a new question about the same issue from a different perspective )
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Version Control

From novice to tech pro — start learning today.