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

unstage file #1104

Open
harilet opened this issue Dec 2, 2024 · 3 comments
Open

unstage file #1104

harilet opened this issue Dec 2, 2024 · 3 comments

Comments

@harilet
Copy link

harilet commented Dec 2, 2024

I was trying to unstage files. I can add file fine by using

let mut index = repo.index().unwrap();
index.add_path(Path::new(&path)).unwrap();

I saw we can use the remove_path like this

let mut index = repo.index().unwrap();
index.remove_path(Path::new(&path)).unwrap();
index.write().unwrap();

but this deletes file not remove changes
Image

what can I do?
and I saw this remove but the 2th parameter stage is an int but have no more detail
https://docs.rs/git2/latest/git2/struct.Index.html#method.remove

@ehuss
Copy link
Contributor

ehuss commented Dec 2, 2024

The 2nd parameter is usually 0 for the main index. Other numbers are used when dealing with merge conflicts and such.

@harilet
Copy link
Author

harilet commented Dec 2, 2024

@ehuss ok I understand that now.

so what can I do to just unstage changes from a file, any ideas?

@ehuss
Copy link
Contributor

ehuss commented Dec 2, 2024

It's index.remove(path, 0)

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

2 participants