Script to Auto-Rebase Multiple Git Repositories

Auto-Rebase Multiple Git Repositories

When preparing releases, I often need to update several repos/branches before merging. Typing the same commands repeatedly gets old, so here’s a small shell script to rebase multiple repos in one go.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
printf "Start rebase 58HouseSearch.\n"
cd ./58HouseSearch
git checkout master
git pull --rebase origin master
printf "Finish Pull Rebase 58HouseSearch master.\n"
read -p "Press any key to continue."
cd ..

printf "Start rebase hexoforblog.\n"
cd ./hexoforblog
git checkout master
git pull --rebase origin master
printf "Finish Pull Rebase hexoforblog.\n"
read -p "Press any key to continue."
cd ..

Notes:

  • printf prints progress messages
  • read -p pauses for confirmation between steps
  • Output mirrors what you see in Git Bash
Licensed under CC BY-NC-SA 4.0
使用 Hugo 构建
主题 StackJimmy 设计