DEV Community

n350071πŸ‡―πŸ‡΅
n350071πŸ‡―πŸ‡΅

Posted on

[git] change remote repository url

πŸ€” Situation

  • changed remote repository url
  • changed GitHub user name

πŸ‘ Solution for a few repositories

git remote -v
git remote set-url origin git@github.com:new_name/repository_name.git
git remote -v

πŸ¦„ Solution for many repositories

echo "git remote set-url origin git@"$(git remote -v | grep fetch | cut -d ' ' -f 1 | cut -d '@' -f 2 | sed -e 's/old_name/new_name/g') | bash

If remote -v shows multiple remote repositories, i.e. origin, github, gitlab.., please adjust the grep command.

πŸ”— Parent Note

Top comments (0)