News for hackers. Stuff that matters.
Re:Multi-gitter – CLI to update multiple Git repositories in... by skywal_l on Tuesday June 28, 2022 @08:20AM (#31906735)
I have this simple script that I find immensely useful when dealing with multiple git repository present in the same folder:

    #!/usr/bin/env bash
    
    if [ $# -lt 1 ]
    then
      echo "$0: error: missing arguments"
      echo "usage: $0 <command> <args...>"
      exit 1
    fi
    
    for folder in `find . -maxdepth 1 ! -path . -type d`
    do
      if [ -d "$folder"/.git ];
      then
        pushd . > /dev/null
        cd "$folder"
        echo -e '\033[1;32m'
        echo `pwd`
        echo -e '\033[0m'
        "$@"
        popd > /dev/null
      fi
    done
    
In a folder with multiple git repos, you will do something like this:

    $ gitall git status
    [...]
    $ gitall git remote update
    [...]
    $ gitall git rebase origin/master
    [...]

There are no comments on this comment yet.