Hi,
I got a bunch of repos I've cloned off GitHub and I'm looking for the
best way to keep them all up to date.
I got a working zsh script, but it lacks some stuff. For instance I
think it'd be neat if it could output the difference between the
commit dates as oppose to those long hashes. And if it could initiate
the pull only when necessary. Other ideas are welcome.
Does anybody have any suggestions to how I might complete or otherwise
improve the below scripts? Thanks in advance.
Here's the working version:
abletony84$ cat pull_all.sh
#!/usr/bin/env zsh
for folder in $PWD/**/.git(:h); do
cd $folder
git pull
done
-
This script lacks a proper if clause, and shows hashes instead of dates:
abletony84$ cat pull_all2.sh
#!/usr/bin/env zsh
for folder in $PWD/**/.git(:h); do
cd $folder
if this repo needs an update; then # git ls-remote has been suggested
old=$(git rev-parse HEAD)
git pull >& /dev/null
new=$(git rev-parse HEAD)
echo "$folder: $old -> $new"
else
echo "$folder: nothing to do"
fi
done
-
A slightly different approach, even more incomplete than the previous:
abletony84$ cat pull_all3.sh
#!/usr/bin/env zsh
for folder in $PWD/**/.git(:h); do
cd $folder
if repo still exists at github; then
git fetch >& /dev/null
if a merge is needed; then
git merge >& /dev/null
echo "$folder: date_of_last_current_commit -> date_of_last_new_comit"
else
echo "$folder: nothing to do"
fi
fi
done
-
Thanks again!
Tony
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html