![git:更改特定檔案的行結尾並重寫歷史記錄](https://rvso.com/image/1586634/git%EF%BC%9A%E6%9B%B4%E6%94%B9%E7%89%B9%E5%AE%9A%E6%AA%94%E6%A1%88%E7%9A%84%E8%A1%8C%E7%B5%90%E5%B0%BE%E4%B8%A6%E9%87%8D%E5%AF%AB%E6%AD%B7%E5%8F%B2%E8%A8%98%E9%8C%84.png)
如同 重寫 git 歷史記錄以將所有 CRLF 替換為 LF?
但僅適用於歷史上的幾個文件,例如:“/path to file/file name with space.txt”和“otherPath/other files.txt”
連結問題的答案將存儲庫中的每個文件更改為 LF 我只想對很少的文件(3-4 個文件)執行此操作。
如果可能的話,我更喜歡只使用 git 工具(因為我在 Windows 中),就像上一個問題的答案一樣:
git filter-branch --prune-empty --tree-filter 'git add --renormalize .' -- --all
答案1
您可能對該工具感興趣bfg
。
brew install bfg
echo anyword0 >> words.txt
echo anyword1 >> words.txt
bfg --replace-text words.txt .git