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

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

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

From: Tony Maserati <hidden>
Date: 2016-06-15 22:47:45

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

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

From: Kumar Appaiah <hidden>
Date: 2016-06-15 22:47:45

On Sat, Nov 21, 2009 at 11:25:20AM +0100, Tony Maserati wrote:
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.
Would mr help?

http://kitenet.net/~joey/code/mr/

Kumar
-- 
Kumar Appaiah
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help