Skip to content

Instantly share code, notes, and snippets.

@sporsh
Last active December 28, 2019 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sporsh/b789371f3da9fcd6fa08 to your computer and use it in GitHub Desktop.
Save sporsh/b789371f3da9fcd6fa08 to your computer and use it in GitHub Desktop.
put this somewhere in your $PATH and run `git changes` in a repo to show differences in your local commits and upstream
#!/bin/bash
# Execute git fetch
git fetch &
# Get the pid of the `git fetch` process
pid=$!
# Characters used for the spinner animation
spin='⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
i=0
printf " "
while kill -0 $pid 2>/dev/null
do
i=$(( (i+1) %10 ))
printf "\r\r${spin:$i:1} "
sleep .05
done
printf "\r\r"
range=${1-FETCH_HEAD}
echo 'UPSTREAM COMMITS:'
git --no-pager log --abbrev-commit --format='%C(red)<- %C(yellow)%h %Cblue%aN %Cgreen%ar %Creset%s' ..$range
echo 'LOCAL COMMITS:'
git --no-pager log --abbrev-commit --format='%C(green)-> %C(yellow)%h %Cblue%aN %Cgreen%ar %Creset%s' $range..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment