diff --git a/src/Helpers/Git.php b/src/Helpers/Git.php index 7482eb8..3383532 100644 --- a/src/Helpers/Git.php +++ b/src/Helpers/Git.php @@ -150,8 +150,14 @@ public static function remoteName( $repo_dir = false ) { $flag = self::repoFlag($repo_dir); $remotes = Shell::run("git $flag remote 2>/dev/null"); - $remotearray = explode(PHP_EOL, $remotes); - return array_shift($remotearray); + $remotearray = array_filter(array_map('trim', explode(PHP_EOL, $remotes))); + + // Prefer 'origin' when multiple remotes exist + if (in_array('origin', $remotearray, true)) { + return 'origin'; + } + + return reset($remotearray) ?: 'origin'; } /**