code: func (w *Worktree) Reset(opts *ResetOptions) error {
  	if err := opts.Validate(w.r); err != nil {
  		return err
  	}
  
  	if opts.Mode == MergeReset {
  		unstaged, err := w.containsUnstagedChanges()
  		if err != nil {
  			return err
  		}
  
  		if unstaged {
  			return ErrUnstagedChanges
  		}
  	}
  
  	if err := w.setHEADCommit(opts.Commit); err != nil {
  		return err
  	}
  
  	if opts.Mode == SoftReset {
  		return nil
  	}
  
  	t, err := w.getTreeFromCommitHash(opts.Commit)
  	if err != nil {
  		return err
  	}
  
  	if opts.Mode == MixedReset || opts.Mode == MergeReset || opts.Mode == HardReset {
  		if err := w.resetIndex(t); err != nil {
  			return err
  		}
  	}
  
  	if opts.Mode == MergeReset || opts.Mode == HardReset {
  		if err := w.resetWorktree(t); err != nil {
  			return err
  		}
  	}
  
  	return nil
  }
docs: // Reset the worktree to a specified state.