Skip to content

Instantly share code, notes, and snippets.

@mhshimul
Created May 19, 2018 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhshimul/09d28fa8ee21f3b55319e8584bc13a15 to your computer and use it in GitHub Desktop.
Save mhshimul/09d28fa8ee21f3b55319e8584bc13a15 to your computer and use it in GitHub Desktop.
#!/bin/bash
DIRS=`ls -l $MYDIR | egrep '^d' | awk '{print $9}'`
# "ls -l $MYDIR" = get a directory listing
# "| egrep '^d'" = pipe to egrep and select only the directories
# "awk '{print $9}'" = pipe the result from egrep to awk and print only the 9th field
# and now loop through the directories:
for DIR in $DIRS
do
echo "setting up ${DIR}"
cd ${DIR}
echo "removing remote origin"
git remote remove origin
echo "adding bitbucket url as remote origin"
git remote add origin https://username@bitbucket.org/<organization>/${DIR}.git
echo "pulling"
git pull
git checkout master
echo "setting upstream branches"
git branch --set-upstream-to=origin/master master
git branch --set-upstream-to=origin/release release
echo "done"
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment