Skip to content

Instantly share code, notes, and snippets.

@qinshulei
Created June 27, 2016 08:00
Show Gist options
  • Save qinshulei/64eababeccd76c11906eccf0399cbfd7 to your computer and use it in GitHub Desktop.
Save qinshulei/64eababeccd76c11906eccf0399cbfd7 to your computer and use it in GitHub Desktop.
create_branch_in_pure_git.sh
#!/bin/bash
for i in $(ls | grep git);do
echo $i;
cd $i;
git show-ref | grep remotes | while read LINE;do
echo $LINE
version=$(echo ${LINE} | awk 'BEGIN { FS = " " } ; { print $1 }');
branch_name=$(echo ${LINE} | awk 'BEGIN { FS = " " } ; { print $2 }');
echo "version : ""${version}";
echo "branch name : ""${branch_name}";
if [ -n version -a -n branch_name ];then
git branch -f $(basename ${branch_name}) ${version}
fi
done
cd .. ;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment