Created
July 20, 2020 04:28
-
-
Save cacharle/0b68c6238f83a0568f566516617901a6 to your computer and use it in GitHub Desktop.
Change remote url of repository for username change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
[ $# -eq 0 ] && echo "Usage $0 REPOSITORY ..." && exit 1 | |
for repo in $@; do | |
if [ ! -d $repo ] || [ ! -d $repo/.git ]; then | |
echo "$repo: Is not a repository" | |
continue | |
fi | |
cd $repo | |
origin_url=`git remote get-url origin` | |
if [ $? -ne 0 ]; then | |
echo "$repo: No remote named origin" | |
cd .. | |
continue | |
fi | |
url=`echo $origin_url | sed 's/HappyTramp/cacharle/'` | |
echo "$repo: Changing remote url to: $url" | |
git remote set-url origin $url | |
cd .. | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment