Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Run this script while in the directory that has all your cloned repos
- # The script should also be located in the same directory (together
- # with all your repos)
- test "$(pwd)" = "$(realpath $(dirname $0))" ||
- (
- echo "You're in the wrong directory :-(" >&2
- exit 9
- )
- set $(ls -l | awk '/^d/ {print $NF}' | xargs)
- for repo in $@; do
- pushd $repo > /dev/null
- IN_BRANCH=0
- if [ -d $repo/.git ]; then
- current_branch="$(git status | awk 'NR==1 {print $NF}')"
- test "$current_branch" = "master" || IN_BRANCH=1
- [ $IN_BRANCH -eq 1 ] && git checkout master > /dev/null
- git pull > /dev/null && echo Repo $repo updated.
- [ $IN_BRANCH -eq 1 ] && git checkout -
- fi
- popd > /dev/null
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement