說我有以下提交歷史:如何在歷史記錄中更改特定提交中的文件?
4317629 Bug-100 : Formatting/Cosmetic Changes
da10348 Bug-100 : Wire Up UI
9b49b0a Bug-100 : Added UI
現在,說我發現,在提交da10348
,我有幾個文件:a.txt
,b.txt
,c.txt
包含我需要刪除/修復線路。
有人能告訴我我該怎麼做嗎?
說我有以下提交歷史:如何在歷史記錄中更改特定提交中的文件?
4317629 Bug-100 : Formatting/Cosmetic Changes
da10348 Bug-100 : Wire Up UI
9b49b0a Bug-100 : Added UI
現在,說我發現,在提交da10348
,我有幾個文件:a.txt
,b.txt
,c.txt
包含我需要刪除/修復線路。
有人能告訴我我該怎麼做嗎?
你必須重訂你的分支上提交你想爲了 改來改去後,在這種情況下,提交所以實際上的歷史,你必須變基 你你想要改變的人之前提交分支( ^
運營商):
git rebase -i da10348^
變化的提交編輯和執行的更改,然後:
git commit -a --amend --no-edit
,並最終完成底墊:
git rebase --continue
請注意,只有在您願意重寫所有想要更改的提交的後代提交的歷史記錄時才能執行此操作。否則,只需在當前主分支的頂端進行更改即可。
如果你想做到這一點,你可以執行
git checkout da10348
# make changes
git commit -a --amend
git rebase --onto <amended-sha> da10348 <your-branch>
或者如果你喜歡互動變基
git rebase -i da10348^
# change "pick da10348" to "edit da10348"
# save, and make changes when rebase -i stops at da10348
這是我覺得最簡單的做一些小的修改,以最新提交的方法,因爲它只需要一個rebase命令(即不需要git rebase --continue
),並且不涉及記憶提交哈希。
git rebase -i origin/master
一個新的提交如果提交尚未根據推到原點,或者git rebase -i HEAD~3
上how far in the history的承諾更改是(可以高估 - 舊的提交不會被更改)f
或fixup
。
使用'git rebase -i 4317629'和'edit' commit'da10348'。 – univerio