DEV Community

Serguey Asael Shinder
Serguey Asael Shinder

Posted on

You Switched Branches to Review a Pull Request and Lost Your Place

You were halfway into a change.

Three files open,
a test half written,
a print statement
you meant to remove.

Then a review request.

Could you take a look,
it is blocking a release.

So you stashed your work,
switched to their branch,
waited for the build,
waited for the editor
to reindex everything,
ran their tests,
left two comments,
and switched back.

The stash was still there.

Your place was not.

The files you had open were closed.

The test you were writing
had lost its reason.

The print statement
reminded you of nothing.

Twenty minutes to review.

Forty minutes
to find out
what you had been doing.

Most of your place
was never in your head.

It was on the screen.

Which files were open,
in what order,
the terminal history,
the warm build,
the half finished line.

That was your memory,
stored in the machine,
and one checkout poured it out.

Git has a quiet answer
most people never use.

worktree add
creates a second directory
from the same repository,
on a different branch,
sharing the history,
not sharing your mess.

Make one called review
next to your project,
and leave it there.

When somebody asks,
check their branch out in that one,
open it in a second window,
and review.

Your own directory
does not move.

The open files stay open.
The half test stays half written.

Close the review window,
and your desk is exactly
how you left it.

The same trick
works for hotfixes,
for checking how main behaves,
for running a slow suite
on one branch
while you write on another.

Then do the other half,
which is not about git.

Reviews do not have to land
the minute they are asked for.

Pick two or three times a day,
after lunch,
before the stand up,
and work through them together,
unless someone says it is blocking.

When it really is,
the worktree means
saying yes
costs you the review
and nothing more.

Your place in the work
is the most expensive thing on your machine.

Stop throwing it away
to look at somebody else's.

– Serguey Asael Shinder

Top comments (0)