D
D
Dmitry2019-10-16 15:48:30
git
Dmitry, 2019-10-16 15:48:30

How to rollback to a commit by id?

Hello, the topic is hackneyed but still incomprehensible.
I made a commit/push in the morning. After that, there were changes that need to be completely reverted and returned to the state of the morning commit.
How to roll back everything to the morning state. And at the same time stay in the main branch.
Made git checkout some_ID
Accordingly received detached HEADalso the requirement to create a new branch.
How next?
1) Revert all changes made since the morning commit everywhere. How to do it?
2) Being on the morning commit, create a new branch and then merge into MASTER?
Tell me how to do it correctly so as not to lose all the data at the time of the morning commit.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg, 2019-10-16
@Austin_Powers

I think git revert will help you solve this problem.

L
lorc, 2019-10-16
@lorc

Switch back to the branch and do
git reset --hard commit-id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question