Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zhouqiang-cl/214cb68d2d1dcf80aab5adbf479e9459 to your computer and use it in GitHub Desktop.
Save zhouqiang-cl/214cb68d2d1dcf80aab5adbf479e9459 to your computer and use it in GitHub Desktop.
create branch in multi repo
# First your should have $TOKEN
base_branch=master
new_branch=release-5.0
repo_list="zhouqiang-cl/charts zhouqiang-cl/research"
set -x
for repo in $repo_list;do
sha=$(curl -H "Authorization: token $TOKEN" https://api.github.com/repos/$repo/git/refs/heads/$base_branch | jq -r '.object.sha')
curl -X POST -H "Authorization: token $TOKEN" \
-d "{\"ref\": \"refs/heads/$new_branch\",\"sha\": \"$sha\"}" "https://api.github.com/repos/$repo/git/refs"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment