0

I have many commits on git when I do git log. Now I want to go back temporarily to a particular older commit and then come back. Si I tried to do git checkout -b myname shaid

However on my Xilinx IDE, it doesn't revert to the older commit.
Since I was on a different branch anyway, I decided to do git reset --hard <commit_d>.

This reflects all the changes.
How do I go back to a commit without doing git reset?

2 Answers 2

1

If I have understood correctly, you want to simply do git checkout <commit_id>, and then again git checkout <branch_name>

Note: This does not change the history, only changes the working tree.

Sign up to request clarification or add additional context in comments.

Comments

0

Checkout your branch at a specific commit

What you have typed is the exact way to do it:

git checkout -b <new_name> <SHA-1> 

if its still doesn't work for some reason try to split it into 2 commands:

git checkout <SAH1-1> git checkout -b <new_name> 

Making changes - detached HEAD

It will get you int o a state called detached head. you will need to create a new branch (second line from above code snippest) at this point to continue your work.

git checkout -b <new_name> 

Since the commit you checked out is not the latest one you cant modify it straight away, this is why you need to checkout new branch.

If you simply want to look around on some files, there is no need to create a new branch ofcourse.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.