I have a git repository folder on a usb taken from a linux machine.
I tried to use these commands:
I guess this is because windows does not allow : in names of file/folders. Is there any way around this?
Use an OS that permits :
in filesystem paths or rename the paths. Them's your options.
If you're stuck on Windows you can brute-force this with core commands, find a workable replacement for the colons. Perhaps you could use url encoding?
git ls-tree -r @ | sed 's,:,%3A,g' | git update-index --index-info
but you'd then have to reverse the process on OS's without those limitations, and no code looking for the unmangled names would find these files, so this only gets you one more step along the way to whatever you're trying to do. It's possible "just don't use Windows for whatever this is" would be best, also possible that's not an option; if this step doesn't get you there you're going to have to explain what you're trying to do here.
edit: one possibility: are you trying to reset just the paths that don't have colons in them? s,:,%3A,g
to /:/d
in the above sed
.