diff --git a/src/Git/FetchAndSetCurrentUserByReplacingCurrentOriginRemote.php b/src/Git/FetchAndSetCurrentUserByReplacingCurrentOriginRemote.php index cde1f5ba..4d71cbf0 100644 --- a/src/Git/FetchAndSetCurrentUserByReplacingCurrentOriginRemote.php +++ b/src/Git/FetchAndSetCurrentUserByReplacingCurrentOriginRemote.php @@ -24,6 +24,8 @@ public function __invoke( UriInterface $uriWithCredentials, string $repositoryRootDirectory ): void { + Shell\execute('git', ['config', '--global', '--add', 'safe.directory', '*'], $repositoryRootDirectory); + try { Shell\execute('git', ['remote', 'rm', 'origin'], $repositoryRootDirectory); } catch (Shell\Exception\FailedExecutionException) { @@ -31,7 +33,6 @@ public function __invoke( $credentialStore = Filesystem\create_temporary_file(); - Shell\execute('git', ['config', '--global', '--add', 'safe.directory', '*'], $repositoryRootDirectory); Shell\execute('git', ['config', 'credential.helper', 'store --file=' . $credentialStore], $repositoryRootDirectory); File\write($credentialStore, $uriWithCredentials->__toString()); Shell\execute('git', ['remote', 'add', 'origin', $repositoryUri->__toString()], $repositoryRootDirectory);