Sharing a Git repository between Windows and Linux

To develop php projects I use Netbeans IDE. Ihave the version 8.2 in the WIndows partition and the version 8.1 in the Linux partition (this is the version provided by the official Software Manager).
From Windows I have setup a git repository hosted in BitBucket: first I have created the repo in BitBucket, then I have initialized a Git repo in Netbeans and I have committed and pushed the whole project.
Then, in Linux, I have cloned the repo in Netbeans providing the url of the repo. Everything went fine: I performed commit and push from Windows, then from Linux, then from WIndows again.
The last time I tried to commit from Linux I've got an error about a corrupted object. Some investigation made me realize that the object was an avi file that for reasons I ignore had been copied in the repo (I had moved some video from another external hard drive to the one where even my project is stored: all files have been copied in the right directory but one of them, and only one, has been copied even in the repo!!).
As explained here, I tried to delete the file and finally I did it, unless it was just a ghost-file or someone put some drug in my drink :)

Once deleted the corrupted object I thought everything was fine, but Git still give me an error about another corrupted object, and this time is not a video, is an empty folder (

So I suspect there is something I'm missing about sharing a repo between Windows and Linux, maybe is just an issue with Netbeans.

Any idea?
Thank you.
LVL 31
Marco GasiFreelancerAsked:
Who is Participating?
nociSoftware EngineerCommented:
What probably happened is that a directory got corrupted.. (somehow)...
I am not sure what the filesystems is.... (NTFS, FAT, ext2)... drivers for both operating systems exist and some may not have the same info as the other.

NTFS - Windows NT Native filesystem, with a reasonable usermode filesystem for Linux.
FAT - There used to be a GOOD FAT (ExFat) filesystem for linux, alas, microsoft sued companies for patent infringement (and extorted money out of them) and Linux FAT isn't completely compatible with Windows NT Fat.... (FAT 12, FAT16 & FAT32 (partly)) is. AFAIK Microsoft receives about $15,-- for each linux that has FAT support (like Android).  So they probably earn more on sold phones then they earn on windows.
The main problem is the OS developers have no definite idea what the patent infringement is about (AFAICT) so a good work around still is tricky.  (It has probably to do with the way filenames are treated, but the deals are all sealed under NDA's).
Also Linux doesn't keep a seconds FAT up to date due to probably the same patent issue.
Ext2FS  is a Linux filesystem, but does have Windows Drivers. Not sure if they also can handel Ext4 with journaling...

My guess is that your filesystem is FAT..
A filesystem level FSCK might help repair things. (Although you may loose files with it.) That fact that after you use the disk in wndows that the name doesn;t show does indicate this. (In ExFAT filenames are stored with: 8.3 Names in capitals, and the lowercase name is stored as extra characters in the FCB's  after the 8.3 name (In Extra headers, as many as needed)..   So if the original 8.3 name is gone, but the lower case is still shown the file is Actualy missing, except that parts of it are still there.  (This mostly should not be a problem).

Either try a  CHKDSK/F from windows or try a fsck -f from linux to repair it.

The mentioning of the use under windows made me think about this. So it is quite important information.
This might have happened when a disk got disconnected, or a system powered down without proper dismount.
(And might be caused by a accidental collision in the FAT tables).
Britt ThompsonSr. Systems EngineerCommented:
I share repos between Linux and Windows regularly and the only thing I run into is issues with different line endings but git just warns about that. You may run into issues if you're using characters in file names that unsupported in Windows or extremely long file paths -

< (less than)
> (greater than)
: (colon)
" (double quote)
/ (forward slash)
\ (backslash)
| (vertical bar or pipe)
? (question mark)
* (asterisk)

Also, check for leading or hanging spaces on file names. If that's not it, see what happens when you use Git outside of your IDE.
Marco GasiFreelancerAuthor Commented:
Thank you Britt for your answer. It just tell me that my problems is not related to sharing the repo and my suspects were wrong :)
I don't have terribly long paths, nor special chars in file names, nothing strange.
git fsck

Open in new window

gives me this output, now:
git fsck
error: object file .git/objects/31/51f5c64bb5fcd17c8f339c827bccd3151343dd is empty
error: object file .git/objects/31/51f5c64bb5fcd17c8f339c827bccd3151343dd is empty
fatal: loose object 3151f5c64bb5fcd17c8f339c827bccd3151343dd (stored in .git/objects/31/51f5c64bb5fcd17c8f339c827bccd3151343dd) is corrupt

Open in new window

And git-repair gives this:
Running git fsck ...
git-repair: /media/marco/WD Elements/Dev/htdocs/wit_CLIENTI/bcfolder_frontend_crazy_wit/.git/objects/31/51f5c64bb5fcd17c8f339c827bccd3151343dd: removeLink: inappropriate type (Is a directory)

Open in new window

The empty folder is not removed, trying to remove using command line or file manager gives me error that it doesn't exist and I'm sure that if I look for that from Windows I'll see it really doesn't exist.

I fear I'll have to initialize a new repo...
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Britt ThompsonSr. Systems EngineerCommented:
Check this article where someone had, what appears to be, an identical issue. This person was able to resolve it -
Marco GasiFreelancerAuthor Commented:
Hey Britt, I read that article but the main issue is that nor Linux nor Windows nor a live distro allow me to delete or move the whole repo: currently I still have 4 folders in .git directory and I can't delete them because  any OS tells me that the directory doesn't exist. This prevent me even to create a new repo (I should  copy source code to another folder and restart from there but it's irritating I can't delete something and even that OS show me something which doesn't exist :D
Marco GasiFreelancerAuthor Commented:
This might have happened when a disk got disconnected, or a system powered down without proper dismount

Yeah, that's the point. Every time I connect an additional external drive the one which is always connected is unmounted and remounted (and if I forget to close the project in Netbeans, it automatically starts to delete file from the server).

So probably this is what happened and this is the lesson for the future:

always close everything before to mount another device

Thank you both
Marco GasiFreelancerAuthor Commented:
Thank you both. A valid lesson for the future.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.