code: def git_commit(repo_dir, message=None, amend=False, stage=True):
      
      if stage:
          git_add_all(repo_dir)
      command = ['git', 'commit', '--allow-empty']
      if amend:
          command.append('--amend')
          if not message:
              command.append('--no-edit')
      if message:
          command.extend(['--message', pipes.quote(message)])
      elif not amend:
          # if not amending and no message, allow an empty message
          command.extend(['--message=', '--allow-empty-message'])
      return execute_git_command(command, repo_dir=repo_dir)
docs: Commit any changes, optionally staging all changes beforehand.