upendra
upendra

Reputation: 2189

How do i reset to my earlier commit?

I have used multiple resets unintelligently and i am now all over the place in my git repository. Here is the output from reflog and my question is how can i go to this commit modify GBSX_script for PstI/MspI enzyme?

a4c0b87 HEAD@{0}: commit: add few changes
a465ae2 HEAD@{1}: reset: moving to HEAD@{8}
31a3dd2 HEAD@{2}: reset: moving to HEAD@{6}
7b4d404 HEAD@{3}: reset: moving to HEAD@{2}
a465ae2 HEAD@{4}: reset: moving to HEAD@{3}
498d4db HEAD@{5}: reset: moving to HEAD@{1}
7b4d404 HEAD@{6}: reset: moving to HEAD^
498d4db HEAD@{7}: reset: moving to HEAD^
a465ae2 HEAD@{8}: reset: moving to HEAD^
31a3dd2 HEAD@{9}: commit: modify GBSX_script for PstI/MspI enzyme
a465ae2 HEAD@{10}: commit: modify GBSX_script for ApeKI enzyme
498d4db HEAD@{11}: commit: add chr txt file for Aspen genome
7b4d404 HEAD@{12}: reset: moving to HEAD^
04aa5f6 HEAD@{13}: reset: moving to HEAD^^
563b93a HEAD@{14}: reset: moving to HEAD^
bc782a6 HEAD@{15}: commit: mend
563b93a HEAD@{16}: commit: add chr txt file for Aspen genome
56884a1 HEAD@{17}: commit: modify GBSX script for ApeK1 for Aspen
04aa5f6 HEAD@{18}: commit: modify chr file to Aspen
7b4d404 HEAD@{19}: commit: modify the GBSX_script.sh script to correct for 2nd enzyme
317ae1e HEAD@{20}: commit: modify the GBSX_script.sh script
a69b9de HEAD@{21}: commit (amend): trying with PST/MSP in the GBSX test script
502c7cb HEAD@{22}: commit (amend): rying with PST/MSP in the GBSX test script
f7046bc HEAD@{23}: commit: add PST/MSP recog sequence
b9ee79a HEAD@{24}: commit: update gitignore after running RE digest script
5ea495a HEAD@{25}: commit: add GBSX test script
f1e4dbc HEAD@{26}: commit: modify gitignore for fa files
c827fc4 HEAD@{27}: commit (initial): add gitignore

Upvotes: 2

Views: 71

Answers (2)

Shawlaw
Shawlaw

Reputation: 568

You can choose to use Git GUI to make it instead of Git Bash.

Open Git GUI, then open your repository.

Among the menu buttons, click the "repository" and select "show all branches' history"(something like this, I can't give you the accurate name because it's not English on my computer). If you didn't work with remote branches, you can just select "show XXX branch's history"(something like this, too).

After your click, a new window whose title starts with "gitk:" will pop out and you can see all the commits you commited in it. Then just right click the commit that you want to reset to and click "reset XXX branch to here".

This is the most intuitionistic way to reset code-version I know. Hope it can help you :)

Upvotes: 0

SomeKittens
SomeKittens

Reputation: 39532

git reset allows you to point at any commit, not just HEAD or HEAD^, so we can use the SHA (leftmost column)

git reset 31a3dd2

If you want to destroy all of your current changes in the codebase (and not just what commit git is currently pointing to), you can use the --hard option.

git reset --hard 31a3dd2

Upvotes: 3

Related Questions