Skip to content

Instantly share code, notes, and snippets.

@samirreza
Created April 19, 2019 13:16
Show Gist options
  • Select an option

  • Save samirreza/5e6bad85d55a28fb58f62d17bbce68b9 to your computer and use it in GitHub Desktop.

Select an option

Save samirreza/5e6bad85d55a28fb58f62d17bbce68b9 to your computer and use it in GitHub Desktop.

Revisions

  1. samirreza created this gist Apr 19, 2019.
    17 changes: 17 additions & 0 deletions changeRemoteUrl.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    directoryContainingAllRepos="" # directory containing all git repo's
    oldGitRemoteServer="" # current remote server url for example gitlab.com
    newGitRemoteServer="" # new remote server url for example git.example.com
    cd $directoryContainingAllRepos
    find * -maxdepth 0 -type d \( ! -name . \) -print | while read dir
    do
    cd $dir
    if [ -d ".git" ]
    then
    remoteUrl1="$(git config --get remote.origin.url)"
    # echo "${remoteUrl1}"
    remoteUrl2=${remoteUrl1/$oldGitRemoteServer/$newGitRemoteServer}
    remoteUrl3=${remoteUrl2/-module}
    git remote set-url origin ${remoteUrl3}
    fi
    cd ..
    done