Last active
April 27, 2020 03:18
-
-
Save naz/0ce8560e77a834a0e1f90b5060e648da to your computer and use it in GitHub Desktop.
update username in your origin remote url
This file contains 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
# OR traverse all repos from parent directory at once running following commmand | |
# traverses all children repositories | |
# outputs current directory | |
# changes color of the output for readability | |
# matches your current origin with your past username and substitutes it with new one | |
# eg.: git@github.com:gargol/Ghost is transformed into git@github.com:naz/Ghost | |
# changes "origin" url to the new address | |
# outputs current origin details | |
find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && pwd && tput setaf 3; git remote --v | grep :gargol | sed -r 's/:gargol/:naz/g' | grep -o 'git@github.com:naz\/[a-zA-Z-]*' | head -1 | xargs git remote set-url origin && git remote --v | grep origin" \; | |
# do above within single repo | |
git remote --v | grep :gargol | sed -r 's/:gargol/:naz/g' | grep -o 'git@github.com:naz\/[a-zA-Z-]*' | head -1 && xargs git remote set-url origin && git remote --v | grep origin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment