addRemote method

Future<GitRemoteConfig> addRemote(
  1. String name,
  2. String url
)

Implementation

Future<GitRemoteConfig> addRemote(String name, String url) async {
  var existingRemote = config.remotes.firstWhereOrNull(
    (r) => r.name == name,
  );
  if (existingRemote != null) {
    throw Exception('fatal: remote "$name" already exists.');
  }

  var remote = GitRemoteConfig.create(name: name, url: url);
  config.remotes.add(remote);

  await saveConfig();

  return remote;
}