可以說我有3個的git承諾:解決方法git的承諾
- 提交的側邊欄的變化
- 提交的頁腳變化
- 提交關於頭變化
現在讓我們假設我已經去了通過靈性覺醒,並意識到只需要在標題和側欄上進行更改,頁腳就很好,不需要更改。
是否有命令可以執行以下操作?:
- 合併提交#3減提交#2
- 刪除提交#2
- 合併提交#3加提交#1
(或使犯#2的任何其它方法因爲它從未發生過)。
可以說我有3個的git承諾:解決方法git的承諾
現在讓我們假設我已經去了通過靈性覺醒,並意識到只需要在標題和側欄上進行更改,頁腳就很好,不需要更改。
是否有命令可以執行以下操作?:
(或使犯#2的任何其它方法因爲它從未發生過)。
您始終可以使用git-revert
恢復單次提交的更改。
給定一個或多個現有提交,恢復相關修補程序引入的更改,並記錄一些記錄它們的新提交。這要求你的工作樹是乾淨的(不需要修改HEAD提交)。
注意:
git revert
用於記錄一些新的提交以反轉一些早期提交(通常只是錯誤提交)的效果。如果您想在工作目錄中丟棄所有未提交的更改,則應該看到git-reset(1),特別是--hard
選項。如果你想提取特定文件,就像在另一次提交中那樣,你應該看到git-checkout(1),特別是git checkout <commit> -- <filename> syntax
。請謹慎使用這些替代方法,因爲它們都會丟棄工作目錄中的未提交更改。
所以:
git revert <commit-id-of-footer-changes>
互動底墊中,可以修改,重新排列,合併的提交,更改消息和更多:
git rebase --interactive
援引的幫助:
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#
失去承諾是你想要的。
您可以使用cherry-pick
合併您想要的提交,然後revert
開發分支在頁腳更改之前提交。
git checkout branch_to_merge_into
git cherry-pick commit#1 commit#3