感谢@Trebor我只是把共同为目的的简单鱼功能:
#! /usr/bin/fish
#
# Echos (to stdout) whether your branch is up-to-date, behind, ahead or diverged from another branch.
# Don't forget to fetch before calling.
#
# @param branch
# @param otherbranch
#
# @echo string up-to-date/behind/ahead/diverged
#
# @example
#
# # if master is ahead of origin/master you can find out like this:
# #
# if test (branch-status master origin/master) = ahead
#
# echo "We should push"
#
# end
#
function branch-status
set -l a $argv[ 1 ]
set -l b $argv[ 2 ]
set -l base (git merge-base $a $b)
set -l aref (git rev-parse $a )
set -l bref (git rev-parse $b )
if [ $aref = $bref ]; echo up-to-date
else if [ $aref = $base ]; echo behind
else if [ $bref = $base ]; echo ahead
else ; echo diverged
end
end
来源
2017-07-30 22:52:38
nus
对于推动部,你将不得不使用Git 2.5+(Q2 2015)'混帐的for-each-REF --format =“%(push:track)”refs/heads'。看到更多[在我的答案](http://stackoverflow.com/a/30720302/6309)。 – VonC