Skip to content

Instantly share code, notes, and snippets.

@aaronjanse
Last active October 14, 2017 19:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronjanse/823718f09724c74ffe2b61cc3549b4c8 to your computer and use it in GitHub Desktop.
Save aaronjanse/823718f09724c74ffe2b61cc3549b4c8 to your computer and use it in GitHub Desktop.
A simple command to check how many commits have not been pushed/pulled

Shows how many commits ahead and behind git remotes are.

How to run:

bash remote_status.sh [remote]

The remote defaults to origin

(optional) Installation:

chmod +x remote_status.sh
echo "alias remote-status=$(pwd)/remote_status.sh" >> ~/.bash_profile
source ~/.bash_profile

You can now run remote-status from anywhere to check on your git remote push/pull status.

Example

$ remote-status
↑2↓3

That above means that you have 2 commits that haven't been pushed, and 3 commits that haven't been pulled.

#!/usr/bin/env bash
printf '↑'
git rev-list ${1:-origin}..HEAD | wc -l | tr -d ' ' | xargs echo -n
printf '↓'
git rev-list HEAD..${1:-origin} | wc -l | tr -d ' '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment