我编写了这个(强力)脚本,使多个存储库保持最新状态。
for app in $(/bin/ls -d $@)
do
cd $app
pwd
git pull
cd ..;
done
请问有更简单的方法吗?
最佳答案
您至少可以简化脚本:
并避免错误:
- Quote your args
- 在
cd
上使用--
以避免参数被解释为选项 - Skip the loop if
cd
fails
for app; do
(
cd -- "$app" || continue
pwd
git pull
)
done
顺便说一句Shellchek是调试 shell 脚本的重要资源。我在那里得到了大部分提示。
关于bash - 除了移动到每个目录之外,是否有 git 或 bash 方式来提取多个 git 存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57367221/