[英]How to revert to a commit but keep the changes
I've a local repo with quite a lot of changes. 我有一个本地仓库,其中有很多更改。 git log --oneline
gives me the following history: 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
Now, I wish to keep the changes after bf8342d
but I dont want the commits made after them to be wiped fro history. 现在,我希望保留bf8342d
之后的更改,但是我不希望它们被历史记录抹掉。 Would be able able to revert to bf8342d
and make it the next commit? 能够还原到bf8342d
并使其成为下一个提交吗? Like this: 像这样:
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
To keep the changes in bf8342d
, you must to make 48d8719
or 7f80737
contain the change. 为了将更改保留在bf8342d
,必须使48d8719
或7f80737
包含更改。 So the commit id after bf8342d
will changes. 因此, bf8342d
之后的提交ID将更改。 Steps as below: 步骤如下:
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
If you want to remove some changes from your branch but want to keep them so you can have them later - move them to other branch. 如果要从分支中删除某些更改,但要保留它们以便以后再使用-将它们移到其他分支。 Call it "experimental" or something like that. 称其为“实验性”或类似的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.