user2516837
user2516837

Reputation:

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:

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. Would be able able to revert to bf8342d and make it the next commit? 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

Upvotes: 1

Views: 5933

Answers (2)

Marina Liu
Marina Liu

Reputation: 38106

To keep the changes in bf8342d, you must to make 48d8719 or 7f80737 contain the change. So the commit id after bf8342d will changes. 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

Upvotes: 2

aragaer
aragaer

Reputation: 17848

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.

Upvotes: 0

Related Questions