KEMBAR78
Can't checkout a file · Issue #1176 · go-git/go-git · GitHub
Skip to content

Can't checkout a file #1176

@rdeusser

Description

@rdeusser

The title might be a misleading, but I can't seem to figure out how to do this git checkout -- ./blah ./foo with the exact behavior in git (i.e. discard unstaged files only). I'd expect it to look something like this:

// Open the repository.
repo, err := git.PlainOpen(path)
if err != nil {
	return err
}

// Get the working directory tree.
w, err := repo.Worktree()
if err != nil {
	return err
}

return w.Checkout(&git.CheckoutOptions{
	Force: true,
	Keep:  true,
        Files: []string{"./blah", "./foo"},
})

I can't find anything in the issues or the codebase that even remotely hints at being able to do this.

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