Git push issue with invalid characters

Hi,
I’ve some old file in my git repo that I need to remove them. Unfortunately there’re special characters like ~ in the name and I think it is here my problem:

remote: FATAL: invalid characters in ref or filename: 'VREF/NAME/modules/cobbler/templates/rhel-XXXXX.cfg.erb~HEAD'
remote:
remote: error: hook declined to update refs/heads/master
To github:puppet
! [remote rejected] master -> master (hook declined)
error: failed to push some refs to 'github:puppet'

After some research I’ve found that it is possible to bypass it with some configuration in .gitolite.rc like this one (at the end of file):
$REF_OR_FILENAME_PATT = qr(^[0-9a-zA-Z][-0-9a-zA-Z._\@/+ :,~]*$);
or this one:
$UNSAFE_PATT = qr([#$&()|<>]);`
Do you have any experience with this? I’m on the right way or do you have any other ideas?
Thanks and best regards, H

Thanks for joining us! We’re glad you’re here :grinning:

I’m not familiar with gitolite but if you need to remove a file from your repository’s history, you can refer to our help topic on removing sensitive data from your repository. Whether you want to remove a file completely from your repository’s history because it contained sensitive information or it has invalid characters in the file path, the process for handling it should be the same.