我有一个本地仓库,有很多变化。git log --oneline
给了我以下历史记录:
fb2d06e Included table view in posters ui
b749eb9 Final Dark theme with Posters before gitflow.
8a8e2c3 Added Dark theme, posters & only 'video' files in jsTree display
ee9b6f4 Segregated semantic dark & light themes
e3bda4c Display and save nly 'video' files
7f80737 Updated dark theme settngs in sematic UI
bf8342d Removed files Accordion
48d8719 Adding multiprocessing
现在,我希望在bf8342d
之后保留更改,但我不希望在历史记录之后删除它们之后的提交。能够恢复到bf8342d
并使其成为下一次提交吗?像这样:
okn3wco Reverted to 'bf8342d'
fb2d06e Included table view in posters ui
b749eb9 Final Dark theme with Posters before gitflow.
8a8e2c3 Added Dark theme, posters & only 'video' files in jsTree display
ee9b6f4 Segregated semantic dark & light themes
e3bda4c Display and save nly 'video' files
7f80737 Updated dark theme settngs in sematic UI
bf8342d Removed files Accordion
48d8719 Adding multiprocessing
答案 0 :(得分:2)
要保持bf8342d
中的更改,您必须使48d8719
或7f80737
包含更改。因此bf8342d
之后的提交ID将发生变化。步骤如下:
git checkout 7f80737
git checkout -b temp
git reset --soft HEAD~2
git commit -m 'Updated dark theme settngs in sematic UI'
git rebase --onto temp 7f80737 <branch before switch to temp>
git branch -D temp
答案 1 :(得分:0)
如果您想从分支中删除某些更改但希望保留它们以便以后可以使用它们 - 将它们移动到其他分支。称之为“实验性”或类似的东西。