Skip to content

Instantly share code, notes, and snippets.

@eeowaa
Last active March 29, 2019 16:01
Show Gist options
  • Select an option

  • Save eeowaa/86b45f7c6c66f854e96f2b9e5d3031aa to your computer and use it in GitHub Desktop.

Select an option

Save eeowaa/86b45f7c6c66f854e96f2b9e5d3031aa to your computer and use it in GitHub Desktop.

Revisions

  1. eeowaa revised this gist Mar 29, 2019. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions git-bulk
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,4 @@
    #!/bin/sh
    # Perform a specific git operation on every repository residing in a child
    # directory of the current working directory.

    # XXX: Hack to get to the cwd of the parent process
    test "X$GIT_PREFIX" = X || cd -- "$GIT_PREFIX"
  2. eeowaa revised this gist Mar 29, 2019. No changes.
  3. eeowaa renamed this gist Mar 29, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. eeowaa created this gist Mar 29, 2019.
    31 changes: 31 additions & 0 deletions git-bulk.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    #!/bin/sh
    # Perform a specific git operation on every repository residing in a child
    # directory of the current working directory.

    # XXX: Hack to get to the cwd of the parent process
    test "X$GIT_PREFIX" = X || cd -- "$GIT_PREFIX"

    # Only return 0 if *everything* succeeds
    rc=0

    # Output a nice header to separate this command from the others
    cat <<EOF
    -------------------------------------------------------------------------------
    GIT BULK COMMAND STARTED: `date`
    -------------------------------------------------------------------------------
    EOF

    # For each child directory containing a `.git' grandchild directory
    ls -d */.git | while read x
    do
    test -d "$x" || continue
    repo=`dirname "$x"`
    echo >&2 "=== $repo ==="

    # Navigate to that directory and do something!
    cd "$repo" && {
    git "$@" || rc=1
    cd ..
    } || rc=1
    done
    exit $rc