code: func (w *Worktree) Commit(msg string, opts *CommitOptions) (plumbing.Hash, error) {
  	if err := opts.Validate(w.r); err != nil {
  		return plumbing.ZeroHash, err
  	}
  
  	if opts.All {
  		if err := w.autoAddModifiedAndDeleted(); err != nil {
  			return plumbing.ZeroHash, err
  		}
  	}
  
  	idx, err := w.r.Storer.Index()
  	if err != nil {
  		return plumbing.ZeroHash, err
  	}
  
  	h := &buildTreeHelper{
  		fs: w.Filesystem,
  		s:  w.r.Storer,
  	}
  
  	tree, err := h.BuildTree(idx)
  	if err != nil {
  		return plumbing.ZeroHash, err
  	}
  
  	commit, err := w.buildCommitObject(msg, opts, tree)
  	if err != nil {
  		return plumbing.ZeroHash, err
  	}
  
  	return commit, w.updateHEAD(commit)
  }
docs: // Commit stores the current contents of the index in a new commit along with
  // a log message from the user describing the changes.