Last active
March 27, 2025 01:14
-
-
Save pps83/61502f62cc13c6569ae88970fb3f8c75 to your computer and use it in GitHub Desktop.
Bash script to rewrite git history of a master branch making sure that line endings are changed to LF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#use https://github.com/newren/git-filter-repo | |
git-filter-repo --file-info-callback ' | |
contents = value.get_contents_by_identifier(blob_id) | |
ext = filename.lower().split(b".")[-1] | |
if ext not in [b"c", b"cpp", b"h", b"hpp"] or \ | |
value.is_binary(contents): | |
# Make no changes to the file; return as-is | |
return (filename, mode, blob_id) | |
new_contents = contents.replace(b"\r\n", b"\n") | |
new_blob_id = value.insert_file_with_contents(new_contents) | |
return (filename, mode, new_blob_id) | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment