I have ISCSI node filenames with colons stored in GIT repository on Debian 10 Linux.
Example:
'iscsi/nodes/iqn.2000-01.com.synology:NAS01-DS916.nas/ff11::111:11ff:ff1f:1ff1,3260,1/default'
'iscsi/send_targets/1.2.3.4,3260/iqn.2000-01.com.synology:NAS01-DS916.nas,ff11::111:11ff:ff1f:1ff1,3260,1,default'
But checkout fails on Windows, because the colon is invalid character in Windows filename.
I get following GIT errors at Windows checkout:
error: invalid path 'iscsi/nodes/iqn.2000-01.com.synology:NAS01-DS916.nas/ff11::111:11ff:ff1f:1ff1,3260,1/default'
...
error: invalid path 'iscsi/send_targets/1.2.3.4,3260/iqn.2000-01.com.synology:NAS01-DS916.nas,ff11::111:11ff:ff1f:1ff1,3260,1,default'
1) How to list all path having colon : in full GIT repo history?
2) How to remove all files from GIT repo history with path having at least one colon : in filename?
CodePudding user response:
The better approach might be to not check those files out on Windows,see the sparse checkout facility, or to rename them with characters Windows can handle, but to answer the questions as asked:
- How to list all path having colon : in full GIT repo history?
git log --all --name-only -m --pretty= -- '*:*' | sort -u
- How to remove all files from GIT repo history with path having at least one colon : in filename?
git filter-branch --prune-empty --index-filter '
git ls-files "*:*" | git update-index --remove --stdin
' -- --all
which will rewrite your entire history starting from the first commit you have to change. Do this in a scratch clone.
CodePudding user response:
- How to list all path having colon : in full GIT repo history?
You may be out of luck here. There's more talk about this issue and workarounds in Windows here.
- How to remove all files from GIT repo history with path having at least one colon : in filename?
Please be careful with this approach if you are developing with others. When existing branches are modified in the origin, it will cause a lot of conflicts when others try to pull them down.
But if you are ok to proceed, you can try an approach here.
CodePudding user response:
link #1 did not provide solution to list paths having colo
Check:
git ls-tree -r master --name-only | grep ":"
But the approach suggested was to reset all files without ":", and delete the rest:
git ls-tree -r master --name-only | grep -v ":" | xargs git reset HEAD
git commit -m "deleting all files with a colon in the name"
git restore -- .