Skip to content

git_worktree_add() and git_worktree_remove() / git_worktree_delete() #251

@DavisVaughan

Description

@DavisVaughan

libgit2 API:
https://libgit2.org/docs/reference/main/worktree/index.html

I had a use case for git worktrees here:
DavisVaughan/cross#8

Basically I wanted to be on my-branch and be able to:

  • Check out main, install the package at main into a specific libpath
  • Check out my-branch, install the package at my-branch into a specific libpath

All while not touching the user's current state while on my-branch

My solution was to:

  • Create a temp branch, main-cross
  • Create a worktree in a temp dir, checkout out main-cross there
  • Create a temp branch, my-branch-cross
  • Create a worktree in a temp dir, checkout out my-branch-cross there

This seems like the right way to do this, but it requires me to go to system git calls. I copied some code from pak that does this, but I'm already using gert so it would be nice to just stay in that ecosystem.

I think minimal support for me would look like:

git_worktree_add <- function(dir, branch) {
}

git_worktree_remove <- function(dir) {
}

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