Skip to content

Add RestoreStaged to Worktree that mimics the behaviour of git restore --staged <file>... #343

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
wants to merge 8 commits into from
Prev Previous commit
Next Next commit
git: worktree, Update the documentation to be more clear and follow t…
…he documentation standards
  • Loading branch information
Ben Talbot committed Jul 14, 2021
commit eac1e381cdd4769303231f06218a7eb1610f8b76
12 changes: 11 additions & 1 deletion worktree.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,17 @@ func (w *Worktree) setHEADToBranch(branch plumbing.ReferenceName, commit plumbin
return w.r.Storer.SetReference(head)
}

// unstages a set of files -- equivalent to "git restore --staged <file>..."
// Restore specified files in the working tree or stage with contents from
// a restore source. If a path is tracked but does not exist in the restore,
// source, it will be removed to match the source.
//
// If Staged and Worktree are true, then the restore source will be the index.
// If only Staged is true, then the restore source will be HEAD.
// If only Worktree is true or neither Staged nor Worktree are true, will
// result in ErrRestoreWorktreeeOnlyNotSupported because restoring the working
// tree while leaving the stage untouched is not currently supported
//
// Restore with no files specified will return ErrNoRestorePaths
func (w *Worktree) Restore(o *RestoreOptions) error {
if err := o.Validate(); err != nil {
return err
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy