Skip to content

Failed worktree add doesn't clean-up #2

Open

Description

@drok

When a worktree add with --branch option fails because the destination dir already exists, the newly created branch is not cleaned up as I expected. When I remove the offending destination dir, and re-run the worktree add, it fails because of existing branch:

bio:radu [Linux] ~/proj/vscode.config  (start)
$ git worktree add -b gnumake/misplaced ../../vscode-autotools/vendor/gnumake/.vscode start
Preparing worktree (new branch 'gnumake/misplaced')
- fatal: '../../vscode-autotools/vendor/gnumake/.vscode' already exists

bio:radu [Linux] ~/proj/vscode.config  (start)
$ git worktree add -b gnumake/misplaced ../../vscode-autotools/vendor/gnumake/.vscode start
Preparing worktree (new branch 'gnumake/misplaced')
- fatal: a branch named 'gnumake/misplaced' already exists

bio:radu [Linux] ~/proj/vscode.config  (start)
$ git branch -d gnumake/misplaced
Deleted branch gnumake/misplaced (was f36fbd7).

bio:radu [Linux] ~/proj/vscode.config  (start)
$ git worktree add -b gnumake/misplaced ../../vscode-autotools/vendor/gnumake/.vscode start
Preparing worktree (new branch 'gnumake/misplaced')
+ HEAD is now at f36fbd7 Start of vscode.config

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions