0

Given the following:

  1. I have a piece of code - one fairly complex file - that I am actively working on and I save/commit/sync often.  Maybe even too often, but that's another story.

  2. Assume my commit versions are represented by the letters "A" through "Z", where "A" is the first commit and "Z" is the latest.

  3. Somewhere in the process of working on the code, I inadvertently introduced a bug that causes it to stop working, but I don't know exactly WHERE in that commit history I accidentally borked my code.

Question #1:
Is it possible, somehow or other, to "walk the commit chain" (so to speak) and pick a particular commit, ("W" for example), grab it, bring it into the workspace, and try it.

Nope, "W" doesn't work either.  Let's try "J".  Ahh!  "J" works, but it's too early and still has a different bug, let's try "N". . .

Eventually I (hope to) find the commit just prior to the problem.

Question 2:
Assuming I can walk the commit chain, and I find the offending version - "R" works, but "S" fails - can I somehow "rewind" the commit history - or do something - to clean up the jumping around I have done and get to the point where "R" is now the current version?

Question 3:
Assuming that questions 1 and 2 get me to a point I want to "put a stake in the ground", should I and/or do I need to rebase to flatten out my commit history?

Question 3a:
Git-Lens provides the ability to "checkout" a particular revision at a particular point in time.

I, (sort-of), understand the idea of "checking something out", but I understand that from the context of something at the end of the commit chain, not the middle.

If my current revision, (last commit), is "Z" and I "checkout" revision "Q", what happens?  Does it change my revision history?  If it doesn't help, can I "put it back" and get something else?

What does this do to my workspace? If "file_x.js" is the offending file, the current version is "Z", and I check out revision "Q", what file do I have in my workspace to run?

Thanks!

Jim JR Harris
  • 413
  • 1
  • 6
  • 15
  • 1
    Does this answer your question? [How to use git bisect?](https://stackoverflow.com/questions/4713088/how-to-use-git-bisect) – mkrieger1 Jan 06 '22 at 22:22
  • @mkrieger1 Possibly, but I'm not sure how to use this within the context of VS Code. I'm hoping for a fair amount of hand-holding as I don't want to make things worse than they are. – Jim JR Harris Jan 06 '22 at 22:39
  • 1
    Sorry dude but SO is not really the place for hand-holding. Read a tutorial on bisect and give it a shot. Come back and ask again if you get stuck on a step in the process. If you want to avoid damaging a sandbox you're already working in, just create a new one on the same code. – joanis Jan 07 '22 at 14:44
  • Sorry, Wasn't hoping for hand-holding from YOU, but from the process itself. – Jim JR Harris Jan 07 '22 at 15:24

0 Answers0