Git - Helpful scripts
Table of Contents
These scripts are helpful when dealing with a lot of repositories.
Save these as .sh scripts. In Windows, .sh scripts can be run from git bash terminal.
Pulling latest changes from develop branch
cd /c/users/username/downloads/GitRepositories/application1
pwd
git remote update --prune
git merge remotes/origin/develop
cd /c/users/username/downloads/GitRepositories/application2
pwd
git remote update --prune
git merge remotes/origin/develop
cd /c/users/username/downloads/GitRepositories/application3
pwd
git remote update --prune
git merge remotes/origin/develop
Checkout develop branch and delete local branches other than develop
cd /c/users/username/downloads/GitRepositories/application1
pwd
git checkout -b develop --track remotes/origin/develop
git branch | grep -ve " develop$" | xargs git branch -D
cd /c/users/username/downloads/GitRepositories/application2
pwd
git checkout -b develop --track remotes/origin/develop
git branch | grep -ve " develop$" | xargs git branch -D
cd /c/users/username/downloads/GitRepositories/application3
pwd
git checkout -b develop --track remotes/origin/develop
git branch | grep -ve " develop$" | xargs git branch -D