我已經開始使用張貼在這一個腳本中另一個thread:扭捏腳本來把所有的遙控器分支
#!/bin/bash
main() {
REMOTES="[email protected]";
if [ -z "$REMOTES" ]; then
REMOTES=$(git remote);
fi
REMOTES=$(echo "$REMOTES" | xargs -n1 echo)
CLB=$(git branch -l|awk '/^\*/{print $2}');
echo "$REMOTES" | while read REMOTE; do
git remote update $REMOTE
git remote show $REMOTE -n \
| awk '/merges with remote/{print $5" "$1}' \
| while read line; do
RB=$(echo "$line"|cut -f1 -d" ");
ARB="refs/remotes/$REMOTE/$RB";
LB=$(echo "$line"|cut -f2 -d" ");
ALB="refs/heads/$LB";
NBEHIND=$(($(git rev-list --count $ALB..$ARB 2>/dev/null) +0));
NAHEAD=$(($(git rev-list --count $ARB..$ALB 2>/dev/null) +0));
if [ "$NBEHIND" -gt 0 ]; then
if [ "$NAHEAD" -gt 0 ]; then
echo " branch $LB is $NBEHIND commit(s) behind and $NAHEAD commit(s) ahead of $REMOTE/$RB. could not be fast-forwarded";
elif [ "$LB" = "$CLB" ]; then
echo " branch $LB was $NBEHIND commit(s) behind of $REMOTE/$RB. fast-forward merge";
git merge -q $ARB;
else
echo " branch $LB was $NBEHIND commit(s) behind of $REMOTE/$RB. reseting local branch to remote";
git branch -l -f $LB -t $ARB >/dev/null;
fi
fi
done
done
}
main [email protected]
它的偉大工程,到目前爲止,但我不知道如何調整它拉各分公司,爲某些原因,它不會拉某些地方分支機構。
第一個例子:我有4個當地分支機構落後於主是當前一個,運行此腳本幾枝(4)是對於偏遠落後被拔出後,但我仍然可以看到背後的主分支遠程像下面的圖片:
第二個例子:運行我得到這個腳本之前,落後2個當地分支機構和當前的(發行版)是好的:
我運行該腳本,我得到這個:
所以,我怎麼能調整到拉「所有」本地分支腳本?
我只看到了'master'的分支作爲上拉後暫時落後。還有其他分支還在後面嗎? –
@TimBiegeleisen我用2個例子更新了我的問題,希望澄清一下 – BPL