Skip to content

Instantly share code, notes, and snippets.

@mariomui
Last active June 14, 2020 09:33
Show Gist options
  • Save mariomui/e05f80240934629bfe5d5a1cca2e65eb to your computer and use it in GitHub Desktop.
Save mariomui/e05f80240934629bfe5d5a1cca2e65eb to your computer and use it in GitHub Desktop.
compares local branch name to remote origin
# @usage checkiff master
# @param {posix1} branchname
# @desc notifies you whether local master is the same as origin/master
# (only works in zshell, in bash the piping generaes a subshell)
function checkdiff() {
git fetch;
git diff $1 origin/$1 | wc -l | {read wc};
if (test $wc -ne "0")
then
echo $wc
echo 'Warning. Master has been updated'
else
echo "Good to go."
fi
}
# this version works for bash and zshell
function cdiff() {
local e="033"
local wc=""
echo $tty
git fetch
wc=$(git diff $1 origin/$1 | wc -l);
if [[ $wc != "0" ]];
then
echo $wc;
echo -e "\\"$e"[1;31mWarning\\"$e"[0m. Master has been updated";
else
echo -e "\\$e[32mGood to go.\\$e[0m";
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment