簡體   English   中英

Git 將更改應用於所有先前提交中的所有文件

[英]Git apply a change to all files in all previous commits

我想對我的 git 歷史記錄中的所有文件應用更改。 更准確地說,我想修改一個特定的行,即作者姓名(它寫在我所有文件的 header 中,我不是在談論 git 作者)從所有 ZBA9F11ECC3492BD61E5Z 歷史記錄中刪除以前的值並更改它由新的。
到目前為止,我已經嘗試使用git filter-branch來執行以下命令: sed -i -e "s/<previous_author>/<new_author>/"當我在單個文件(<previous_author>確實被文件中的 <new_author> 替換)。
但是,當我使用git filter-branch -f --tree-filter 'sed -i -e "s/<previous_author>/<new_author>/"' HEAD時,我收到錯誤sed: -i may not be used with stdin . 我試圖用git rebase做類似的事情,但我得到了同樣的錯誤。
那么有沒有辦法做到這一點,所以要對我之前提交的所有文件執行sed -i -e "s/<previous_author>/<new_author>/" 提前致謝。

你可以嘗試類似的東西

git filter-branch -f --tree-filter \
'if git grep --name-only "@author";  
 then
    git grep --name-only "@author" | xargs sed -i -e "s/@prev_auth/@new_author/"
 fi'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM