Sequence of events:
- I add code adding a feature
X
. It works, I push it to our company's GitHub. - Couple of coworkers pull my code and do some refactoring to make it match the API with existing feature
Y
. As part of this, they delete significant parts of the code forX
that was basically duplicated with similar code forY
. - They run some tests. Seems good. They squash their commits together with mine, also rebase on main, and push to GitHub. (I was unaware of this.)
- Couple days later, they notice that one part isn't working right: an example piece of code that worked when I pushed, is no longer working correctly. We try to debug, and can't find anything wrong. They ask me if I can help fix it.
- I try to pull from GitHub. Because of the rebasing and squashing, GitHub gives me a bunch of errors and like 50x merge conflict hell. I just delete my git directory out of frustration and pull it fresh.
- I start debugging and see the squashed commit. It turns out the bug was there by the time the squash was done, i.e. the bug was introduced during their refactoring. At this point we're pretty sure the culprit is the large chunk of "duplicate" code for X that they deleted, and we want to go back to the correctly functioning original verison, where X had its own implementation.
So the code we need isn't visible on GitHub, because it was added and then deleted in the same squashed commit. I don't have a local copy of the code, because I deleted my git directory. I just want to know how to see what's inside the squashed commit. Some people have told me this isn't possible, but that doesn't make any sense; the whole point of git is to not lose data, and the whole point of GitHub is to keep a copy even if it's deleted locally. I pushed the code to GitHub so I'm sure it's still there. I just need help figuring out how to find it my git folder or whatever.
Thanks!