Skip to content

Cryptic error returned if you have local changes #5

@willcl-ark

Description

@willcl-ark

If you have local changes and try to run gh worktree pr [num] <path> without first commiting or stashing, then you see a seemingly unrelated error message, e.g.

$ gh worktree pr 12345 /home/will/src/project-12345
fatal: invalid reference: RemoteBranchName
Error: exit status 128
Usage:
  worktree pr [pr number] <path> [flags]

Flags:
  -h, --help   help for pr

exit status 128

Running with git shows the full issue:

$ gh pr checkout 12345
remote: Enumerating objects: 79, done.
remote: Counting objects: 100% (67/67), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 79 (delta 65), reused 65 (delta 65), pack-reused 12
Unpacking objects: 100% (79/79), 45.43 KiB | 969.00 KiB/s, done.
From https://github.com/my/project
 * [new ref]               refs/pull/12345/head -> RemoteBranchName
error: Your local changes to the following files would be overwritten by checkout:
        src/my_file.cpp
Please commit your changes or stash them before you switch branches.
Aborting

Would be neat if this plugin propagated errors a bit more fully?

Ps thanks for the plugin, really enjoy it!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions