How to go to specific commit in git
I have commited in git and i want to go to the second commit.I have used
git checkout <commit id>
commit 3f54a651504adc885a71db275e0fb4a5a1111cf4 (HEAD -> dev_coder, origin/dev_coder)
Author: Coder <[email protected]>
Date: Sun Jun 27 20:23:48 2021 +0530
button
commit 362d11072139bda8569dcf37012174258e8078c3
Author: Coder <[email protected]>
Date: Fri Jun 25 14:30:01 2021 +0530
updated owner
commit 0db31695b550748c27486248974ee6f57c88458
Author: Coder <[email protected]>
Date: Wed Jun 16 21:25:28 2021 +0530
Added field
commit 2c72f1ef0bd6a6e7da785212a05efa08a308f1fa
Author: Coder <[email protected]>
Date: Fri Jun 11 10:36:01 2021 +0530
I am in a branch call dev_coder and not in the main branch.I want to go to the 362d11072139bda8569dcf37012174258e8078c3 commit.When i used the bellow one it chages the branch and show somethign else.
git chekout 362d11072139bda8569dcf37012174258e8078c3
Your question title is : "How to go to specific commit in git", and actually, you have already achieved that : git checkout 362d110
will set your repository to the state in that commit.
Typing a straight commit hash as a target, however, also sets your repo to a so called "detached HEAD" state, which may be disturbing if you are new to git.
If your intention is to work on a new branch starting from there, you can create a branch, and instruct git to use it as the active branch :
git branch my-work
git checkout my-work
# you will now be working on a branch named 'my-work'
There is actually a shortcut to do this in one single command :
git checkout -b my-work