git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Help creating script that mass-pulls Git(Hub) repos

From
TMTony Maserati <abletony84@gmail.com>
Date
Nov 21, 2009, 10:25 UTC
Message-ID
<dc191bcd0911210225k3cf946c6k54f1287c818af5a8@mail.gmail.com>
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
Next: Kumar Appaiah
Message 1 of 2 in “Help creating script that mass-pulls Git(Hub) repos”
  1. Tony MaseratiNov 21, 2009
  2. Kumar AppaiahNov 21, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.