我正在嘗試重寫 git 存盤庫歷史并應用新的pre-commit鉤子:
- 接受每一次提交
- 應用
pre-commit掛鉤 - 保留原始元資料(作者、日期、訊息)
- 手動解決沖突,如果有的話(鉤子可以改變提交)
- 提交一個新的回購
最終狀態是具有不同提交歷史的新倉庫。
我已經發現:
cherry-pick不運行pre-commit鉤子。- 我可以
git cherry-pick --no-commit
git commit --no-edit
但它不保留提交日期。此外,不確定如何為歷史上的每個提交執行此操作(除非我為此撰寫了一個例如 Python 腳本)。
關于如何有效地做到這一點的任何想法?
uj5u.com熱心網友回復:
使用--exec標志 to git rebase,可能與自定義GIT_SEQUENCE_EDITOR一起跳過帶有選擇串列的互動式提示。所以像:
GIT_SEQUENCE_EDIT=cat git rebase --root --exec .git/hooks/pre-commit
這將在選擇串列中的exec .git/hooks/pre-commit每個之后添加。pick <commit>如果pre-commit鉤子失敗,那將中斷rebase:
Executing: .git/hooks/pre-commit
warning: execution failed: .git/hooks/pre-commit
You can fix the problem, and then run
git rebase --continue
您可以手動解決問題,然后git rebase --continue.
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/521444.html
標籤:混帐githooks预提交钩子git-cherry-pickgit-rewrite-历史
