Skip to content

Instantly share code, notes, and snippets.

@ajitatif
Created January 18, 2021 17:05
Show Gist options
  • Save ajitatif/327e1c4a8384a4f2286b920b627ebcb2 to your computer and use it in GitHub Desktop.
Save ajitatif/327e1c4a8384a4f2286b920b627ebcb2 to your computer and use it in GitHub Desktop.
A bash script to check if there are any git changes in the first level children of current directory. Only works on the same branch of the local copy.
#! /bin/bash
for game in $(ls -1); do
if [[ -d $game ]]; then
cd $game
git fetch
HEADHASH=$(git rev-parse HEAD)
REMOTEHASH=$(git rev-parse $(git branch --show-current)@{upstream})
if [ "$HEADHASH" != "$REMOTEHASH" ]; then
echo "Updating $game"
git pull
fi
cd ..
fi
done
@ajitatif
Copy link
Author

first thanks go to Christian Engvall for the blog post here: https://www.christianengvall.se/check-for-changes-on-remote-origin-git-repository/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment