Skip to content
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

Add Keep to ResetOptions #1031

Open
kkrime opened this issue Feb 20, 2024 · 2 comments
Open

Add Keep to ResetOptions #1031

kkrime opened this issue Feb 20, 2024 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@kkrime
Copy link

kkrime commented Feb 20, 2024

When running:

err = wt.Reset(&git.ResetOptions{ Mode: git.HardReset })

Untracked files are over written.

when running the git equivalent
git reset HEAD --hard

untracked files are left alone.

Also, when running:
wt.Checkout(&git.CheckoutOptions{Branch: plumbing.ReferenceName("refs/heads/main"), Force: true})
Untracked files are over written.

when running the git equivalent
git checkout main -f

untracked files are left alone.

I think that the behaviour should be the same, as untracked files are not apart of the repo and this is causing me issues with my work.

@pjbgf
Copy link
Member

pjbgf commented Mar 14, 2024

git checkout

As per official documentation the -f / --force:

This is used to throw away local changes and any untracked files or directories that are in the way.

Which should be the same behaviour as you get with Force. To keep the untracked files, use Keep instead.

git reset

We could explore adding a Keep option for Reset so they are largely aligned.

@pjbgf pjbgf added enhancement New feature or request help wanted Extra attention is needed labels Mar 14, 2024
@pjbgf
Copy link
Member

pjbgf commented Mar 14, 2024

Renaming the issue to align with the gap we have in go-git.

@pjbgf pjbgf changed the title Inconsistencies between git and go-git Add Keep to ResetOptions Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants