I have a useful method to create a remote git alias, if not exists, and fetch data. I used it in Powershell scripts to operate with git remote branches:
function FetchRemote( $remoteAlias, $remoteRepository, $remoteBranch)
{
$aliasFound= & git remote | out-string -stream | select-string $remoteAlias
if([string]::IsNullOrEmpty($aliasFound))
{
git remote add -f -t $remoteBranch –no-tags $remoteAlias $remoteRepository
}
else
{
git fetch $remoteAlias
}
}