Skip to main content

discard_file_changes

Function discard_file_changes 

Source
pub fn discard_file_changes(
    repo_path: &Path,
    file_path: &str,
    staged: bool,
) -> Result<(), String>
Expand description

Discards uncommitted changes in file_path.

  • If the file is untracked, it is deleted from the filesystem.
  • If the file is tracked and modified/deleted, it is restored from the index.
  • If the file is staged, it is first unstaged (reset to HEAD) and then restored from index.