Skip to content

Instantly share code, notes, and snippets.

@dc0d
Created March 14, 2023 08:11
Show Gist options
  • Select an option

  • Save dc0d/0625a9390917d02b8e71bd91aedfa474 to your computer and use it in GitHub Desktop.

Select an option

Save dc0d/0625a9390917d02b8e71bd91aedfa474 to your computer and use it in GitHub Desktop.

Revisions

  1. dc0d created this gist Mar 14, 2023.
    22 changes: 22 additions & 0 deletions git-worktree.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    ```
    workspace <- just a plain directory
    ├── main <- main checkout
    ├── branch1
    ├── branch2
    └── branch3
    ```

    list of worktrees
    ```
    git worktree list
    ```

    add a new worktree and a new branch (with the same name) - we are inside the `main` directory
    ```
    git worktree add ../branch4
    ```

    add a new worktree and checkout an existing branch
    ```
    git worktree add ../some-worktree some-existing-branch
    ```