init method

  1. @override
Future<GitWorkingRepository> init(
  1. String path, {
  2. String? initialBranch,
  3. bool allowOccupied = false,
})
override

Creates a new repository with a work tree at path and opens it.

path is a directory: git creates it, missing parents included, and an existing empty directory is used as it stands. A directory that already holds files is refused with GitOccupiedDirectoryException, its content untouched, before git runs; allowOccupied hands such a directory to git instead, which reinitializes an existing repository and keeps its data. initialBranch makes HEAD point at that branch; without it git's own default applies.

A path is always treated as a path, even when it is spelled like an option.

Implementation

@override
Future<GitWorkingRepository> init(
  String path, {
  String? initialBranch,
  bool allowOccupied = false,
}) async {
  await _init(path,
      initialBranch: initialBranch, allowOccupied: allowOccupied);
  return openWorking(path);
}