How to find a bug in origin with git tools

441 views Asked by At

I develop my app locally (in my own branch), but I can only test it on a remote dev server, by pushing to a git repo (my own branch) on the server, and then testing a working copy there.

As I can't find out why my web app crashed, I want to find the last "good" state to understand the reasons. I thought about using git bisect. But it changes just the state of local repo, not origin, and I can't test locally if it works. So what should I do then to check out different commits on remote branch easily (not putting much mess in commit history)?

2

There are 2 answers

1
sleske On BEST ANSWER

If I understand correctly, you develop your app locally, but you can only test it on a remote server, by pushing to a git repo on the server (and then checking out a working copy there, I suppose).

In that case, you will have to run git bisect on the working copy on the remote system. git bisect does not create new commits or new branches, it just checks out different commits (thus putting you into "detached HEAD" state). Therefore there you cannot push the intermediate states created by git bisect to a remote (technically you could, but you'd have to force-push every time, and you'd then need to fix things up in the remote working copy anyway, so that would not help you).

But as I see (correct me if I'm not catching the idea right), git bisect changes just the state of my local repo, not origin.

Yes, exactly. To be precise, it only changes which commit is currently checked out in your local working copy.

TL;DR:

Log in to the remote server, and run git bisect there. If you can only access the server by pushing there, then you're on your own - git does not support this (at least not without a few ugly hacks).

0
Konst54 On

As I had access to server only by pushing there, finally I found the toxic commit by making a new bugsearch branch, and cutting off commits there:

git checkout -b konst54bugsearch

git reset --hard HEAD~1
git push origin +konst54bugsearch
[check the app, repeat reset and force push]

(Actually I could do something like git reset --hard HEAD~20 to approximate where the bug is, like bisect, but I knew it won't be too far).

As I found the commit, I reverted it in konst54 branch, got a working app with quite clean history in my branch, and plan to delete messed konst54bugsearch branch now.