假设我有一个包含多个分支的 git 存储库。我怀疑有些分支没有被推到上游,或者已经过时,或者两者兼而有之(即分歧)。
有没有一种方法可以通过一个命令找出哪些分支与远程不同步? (写一个脚本是可以的,但我想知道是否已经有这样的脚本)。
我已经做了一个脚本。事实证明git branch -v
提供必要的信息。
〜/ bin / git-total.sh:
#!/bin/sh
for DIR in "$@"; do
# Only git dirs interesting
[ -d "$DIR/.git" ] && cd "$DIR" || continue
# git branch -v gives ahead/behind info
# using perl - sorry for this
MOD=`git branch -v | perl -wlne '/^..(\S+)\s+([a-f0-9]+)\s+(\[ahead\s+(\d+)\])/ or next; print "# Branch ahead: $1"; '`;
# a series of UGLY HACKs to get pretty-printing
[ ! -z "$MOD" ] && MOD="
$MOD"
git status | grep -q '^# Changes' && MOD="$MOD
# Uncommitted changes present"
# print summary
[ ! -z "$MOD" ] && echo -e "$DIR:$MOD"
cd -
done
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)