Reputation: 563
I currently have a Project(JavaScript) with a bug in it and I am sure that I fixed it sometime ago, now my Question is how to revert to an old commit and check that Version on my localhost.
But I do not want to loose any changes in my git repo I just want to check how the Project look at commit X, how do I manage that.
I am using gitkraken as a gui.
Upvotes: 3
Views: 3187
Reputation: 15624
If you are unsure when the bug was introduced/fiex you can use the bisect approach of git: https://git-scm.com/docs/git-bisect
git bisect start
git bisect bad COMMIT_KNOWN_TO_FAIL
git bisect good COMMIT_KNOWN_TO_PASS
Then git will select a commit in the middle. You can do your check and depending on the result of your test you call:
git bisect good
if the test passes and
git bisect bad
if the test fails.
Then git selects another commit towards the former good if the test failed and towards the **bad* if the test passed.
Since you're looking for when the problem disappeard you might have to switch the meaning of "good" and "bad" when continuing...
when you identified the malicios commit call
git bisect reset
Upvotes: 0
Reputation: 14539
Branch
button)Reset <branchname> to this commit
> Hard - discard all changes
. This will reset the branch you just created to this commit.EDIT: There's an even easier way!
Create branch here
. Enter a branch name. This will create a branch at this commit.Upvotes: 3