Skip to content

Instantly share code, notes, and snippets.

@pps83
Last active March 27, 2025 01:14
Show Gist options
  • Save pps83/61502f62cc13c6569ae88970fb3f8c75 to your computer and use it in GitHub Desktop.
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
#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