Skip to content

Instantly share code, notes, and snippets.

@rkhozinov
Last active September 13, 2019 11:10
Show Gist options
  • Save rkhozinov/40967ebf1016ce9d57e0292c12448279 to your computer and use it in GitHub Desktop.
Save rkhozinov/40967ebf1016ce9d57e0292c12448279 to your computer and use it in GitHub Desktop.
The script allows to move branches to the $prefix/
#!/usr/bin/env bash
# put the list of branches here
branches=(
branch1
branch1
)
prefix=rkh
author=Ruslan
for branch in "${branches[@]}"; do
data=$(git --no-pager show -s --pretty="%an %d" "${branch}")
if [[ "$data" =~ .*$author* ]]; then
git checkout $branch
git checkout -b $prefix/$branch;
git push --set-upstream origin $(git status | grep "On branch" | cut -c 11-)
git branch -D $branch
git push origin :${branch}
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment