Skip to content

Instantly share code, notes, and snippets.

@YannickFricke
Created February 1, 2019 00:36
Show Gist options
  • Save YannickFricke/b81027c18c7afacbb1e243d910b1707f to your computer and use it in GitHub Desktop.
Save YannickFricke/b81027c18c7afacbb1e243d910b1707f to your computer and use it in GitHub Desktop.
Git auto push branch
#!/bin/bash
while [[ true ]]; do
CURRENT_DATE=$(date "+%d.%m.%Y %H:%M:%S")
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
clear
echo "$CURRENT_DATE Checking for branch: $CURRENT_BRANCH"
if [[ $(git fetch -q origin $CURRENT_BRANCH && git log --oneline $CURRENT_BRANCH...origin/$CURRENT_BRANCH | wc -l) -gt 0 ]]; then
git push -q -u origin $CURRENT_BRANCH > /dev/null
echo "Updated remote repository! \\o/"
else
echo "Nothing to do! \\o/"
fi
sleep -c 30 > /dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment