Yes, the repository database is usually portable across all modern operating systems, including Windows. It doesn't rely on any extended attributes, and so far doesn't rely on case-sensitivity either. Filenames inside the database seem to be 52 characters max.
The main requirement is that filenames preserve their case, even on case-insensitive filesystema (e.g. if you copy .git/HEAD from ext4 to FAT32 to APFS to HFS+ to ext4, it should remain .git/HEAD and not become .git/head). Fortunately all filesystems listed above are case-preserving so that's fine.
One thing to keep in mind is that each branch or tag is represented as a separate file under .git/refs. Git imposes a strict character-set limit in order to work with any filesystem, but that isn't always enough – if you are moving to a case-insensitive filesystem (such as APFS or NTFS) better hope that the repository doesn't contain multiple branches or tags differing only in case. Likewise, Git doesn't forbid the use of legacy DOS device names such as aux
or nul
as branch/tag names.
(Technically, moving the repo across different filesystems might lose some file metadata such as the "read-only" (a-w
) state of object blobs, but this is not something that Git itself looks at anyway.)
If you use FAT32 only as a temporary transport, consider using git pack-refs --all --prune
and rm -rf .git/logs
to avoid any branch-name issues, as unlikely as they are. Also run a git repack -d; git prune
to reduce the number of loose object files.
You can even use git bundle
to create a transport-friendly blob containing all or part of commit history.
.gitattributes
file.