Currently my organization uses ssh instead of https for Bitbucket. So when one does a
git remote get-url origin
It returns something like...
[email protected]:myorg/myrepo.git
I would like to create an alias that replaces the [email protected]:
with https://bitbucket.org/
to show what the https url would be.
Something like
rr = "!f() { ref=$(git remote get-url origin); echo $ref; }; f"
Except where the echo $ref
is, it should do the above replacement instead. I just can't seem to find a good example of doing this sort of string replacement for a git alias function.
CodePudding user response:
replace the :
and then the git@
git remote get-url origin|sed 's!:!/!g'| sed 's!^git@!https://!g'
CodePudding user response:
This seems to work but I marked Ôrel answer above https://stackoverflow.com/a/72888991/222434
rr = "!f() { ref=$(git remote get-url origin); startcmd=$(echo \"$ref\" | sed -r 's|[email protected]:|https://bitbucket.org/|g'); echo $startcmd; }; f"