pub fn reset_head(&self) -> anyhow::Result<()> {
        let mut origin = self.repository.find_remote("origin")?;
        let original_head = self.head_oid()?;
        origin.fetch(
            // Force overwrite (`+` prefix) local master branch with the server's master branch.
            // The git CLI will refuse to fetch into the current branch of a non-bare repo
            // but libgit2 doesn't seem to prevent this potential footgun.
            // The entire point is to do a hard reset, so this footgun is not a concern.
            &["+refs/heads/master:refs/heads/master"],
            Some(&mut Self::fetch_options(&self.credentials)),
            None,
        )?;
        let head = self.head_oid()?;

        if head != original_head {
            println!("Resetting index from {original_head} to {head}");
        }

        let obj = self.repository.find_object(head, None)?;
        self.repository.reset(&obj, git2::ResetType::Hard, None)?;
        Ok(())
    }
/// Fetches any changes from the `origin` remote and performs a hard reset
/// to the tip of the `origin/master` branch.
Fetches any changes from the `origin` remote and performs a hard reset
to the tip of the `origin/master` branch.
Fetches any changes from the ` origin ` remote and performs a hard reset to the tip of the ` origin / master ` branch .
pub fn reset_head(&self) -> anyhow::Result<()> {
        let mut origin = self.repository.find_remote("origin")?;
        let original_head = self.head_oid()?;
        origin.fetch(
            // Force overwrite (`+` prefix) local master branch with the server's master branch.
            // The git CLI will refuse to fetch into the current branch of a non-bare repo
            // but libgit2 doesn't seem to prevent this potential footgun.
            // The entire point is to do a hard reset, so this footgun is not a concern.
            &["+refs/heads/master:refs/heads/master"],
            Some(&mut Self::fetch_options(&self.credentials)),
            None,
        )?;
        let head = self.head_oid()?;
        if head != original_head {
            println!("Resetting index from {original_head} to {head}");
        }
        let obj = self.repository.find_object(head, None)?;
        self.repository.reset(&obj, git2::ResetType::Hard, None)?;
        Ok(())
    }
pub fn reset_head ( & self ) -> anyhow :: Result < ( ) > { let mut origin = self . repository . find_remote ( " " ) ? ; let original_head = self . head_oid ( ) ? ; origin . fetch ( // Force overwrite (`+` prefix) local master branch with the server's master branch. // The git CLI will refuse to fetch into the current branch of a non-bare repo // but libgit2 doesn't seem to prevent this potential footgun. // The entire point is to do a hard reset, so this footgun is not a concern. & [ " " ] , Some ( & mut Self :: fetch_options ( & self . credentials ) ) , None , ) ? ; let head = self . head_oid ( ) ? ; if head != original_head { println ! ( " " ) ; } let obj = self . repository . find_object ( head , None ) ? ; self . repository . reset ( & obj , git2 :: ResetType :: Hard , None ) ? ; Ok ( ( ) ) }
Fetches any changes from the `origin` remote and performs a hard reset
to the tip of the `origin/master` branch.
Fetches any changes from the ` origin ` remote and performs a hard reset to the tip of the ` origin / master ` branch .
&self