Skip to content

Can't checkout a file #1176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rdeusser opened this issue Aug 29, 2024 · 0 comments
Closed

Can't checkout a file #1176

rdeusser opened this issue Aug 29, 2024 · 0 comments

Comments

@rdeusser
Copy link

rdeusser commented Aug 29, 2024

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.

BeChris added a commit to BeChris/go-git that referenced this issue Jan 5, 2025
pjbgf added a commit that referenced this issue Jan 15, 2025
git: worktree, fix restoring dot slash files. Fixes #1176
@pjbgf pjbgf closed this as completed in 4949135 Jan 15, 2025
pjbgf added a commit that referenced this issue Jan 15, 2025
git: worktree, fix restoring dot slash files (backported to v5). Fixes #1176
pjbgf pushed a commit to pjbgf/go-git that referenced this issue Jan 28, 2025
pjbgf pushed a commit to pjbgf/go-git that referenced this issue Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant