Tuesday, 20 November 2012

Update all your git repos in one go

I have a root directory where I clone all my git repos to.  Something like C:\GitRepositories.

Making sure I have the latest of each repository used to be a bit mechanical.

So I wrote a script.  It is sitting in my C:\GitRepositories directory.

I call it updateAll.sh

Here it is:

#!/bin/sh

ls -l -d */ > temp.txt

while read line

do

    gawk '{print $NF}' | sed s/.$//

done < temp.txt > out.txt

rm temp.txt

echo "Updating the following repos:"

less out.txt

while read line

do

    cd $line

    git pull

    cd ..

done < out.txt

rm out.txt

My new home for these kinds of scripts are here.

Come visit my other site at fullcirclesolutions.com.au.  All my best ideas are distilled into commercial tools and made available for purchase.

Till next time....

No comments:

Post a Comment