I am working on a project named XXX.
I want to replace every instance of XXX to YYY. (I wish to replace the string inside all files and also rename files/directories that contain the string XXX to YYY).
What I have done and where I’m stuck:
git checkout -b renameFix
// in zsh
sed -i -- 's/XXX/YYY/g' **/*(D.) // replace
zmv '(**/)(*XXX*)' '$1${2//XXX/YYY}' // rename files and dirs
Now, when I run git status, I get "fatal: unknown index entry format 0x2f700000" error.
Is there a different approach I can use?
>Solution :
Your problem is that your glob (**/*(D.)) traverses the .git directory.
You can add either remove the (D.) quantifier, to avoid globbing "hidden" files (files that start with a period) or add another quantifier, something like:
ignore_git() { ! [[ $REPLY =~ "^.git" ]] }
printf '%s\n' **/*(D.+ignore_git)
I have added the printf so that you can verify that you globs the files that you want.
You can also take a look at git ls-files which can produce a list of files that git tracks.