Search code examples
gitgit-bisectbisectgit-detached-head

How to find a bug in origin with git tools


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)?


Solution

  • 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).