I have a pull request I would want to review locally in a git work tree:
$ git ls-remote origin 'pull/*/head'
d... refs/pull/2/head
This pull request has a branch main
. The documentation of git-worktree
tells me that I can add a new worktree by using the following syntax:
add <path> [<commit-ish>]
Then again, a previous discussion on what is a <commit-ish>
gives me at least the following alternatives for this ish-creature:
----------------------------------------------------------------------
| Commit-ish/Tree-ish | Examples
----------------------------------------------------------------------
| <refname> | master, heads/master, refs/heads/master
| <refname>@{upstream} | master@{upstream}, @{u}
What is the correct format for <commit-ish>
for this pull request?
Every format I have tried so far has failed, including – but not limited to – the following:
$ git worktree add ~/tmp/pr-2-review refs/pull/2/head
fatal: invalid reference: refs/pull/2/head
$ git worktree add ~/tmp/pr-2-review refs/pull/2/head@{upstream}
fatal: no such branch: 'refs/pull/2/head'
$ git worktree add ~/tmp/pr-2-review refs/pull/2/head/main@{upstream}
fatal: no such branch: 'refs/pull/2/head/main'
$ git worktree add ~/tmp/pr-2-review pull/2/head@{upstream}
fatal: no such branch: 'pull/2/head'
$ git worktree add ~/tmp/pr-2-review pull/2/head/main@{upstream}
fatal: no such branch: 'pull/2/head/main'