Reviewing Pull Requests With Git Worktrees

Reviewing Pull Requests With Git Worktrees

20 October 2026 · By Laravel Git · 1 min read

Reviewing a pull request properly means running it, not just reading the diff. Switching your working copy back and forth costs your uncommitted state every time. Worktrees sidestep that.

Check out the PR next to your work#

git fetch origin
git worktree add ../myapp-pr-42 pr-42-branch

You get a second directory on the PR branch while your main checkout stays exactly as it was.

Give it its own environment#

A Laravel app needs more than the code:

cd ../myapp-pr-42
composer install
cp ../myapp/.env .env

Then change what must not clash: APP_URL and port if you serve both at once, and DB_DATABASE to a throwaway database so the PR’s migrations do not touch your dev data:

php artisan migrate --seed
php artisan serve --port=8001

Tear it down cleanly#

git worktree remove ../myapp-pr-42

The branch stays until you delete it; the directory and database go.

When it pays#

One PR a month is fine to stash and switch. A team merging daily needs the review to be cheap, and cheap means the PR runs in its own directory while your own work never moves.

Share this post

Our network