linux - How to create a git alias to recursively run a command on all submodules? -


i have following command run manually:

$ git fetch --all && git reset --hard @{u} && git submodule foreach --recursive "git fetch --all && git reset --hard @{u}" 

i'm using git v2.13.0. goals are:

  1. run specified command on parent (current) repository first.
  2. execute same command on submodules, recursively.

i tried create alias so:

[alias]     run = !f() { \"$@\" && git submodule foreach --recursive \"$@\"; }; f" 

which run (using earlier example):

$ git run "git fetch --all && git reset --hard @{u}" 

however following error (with git trace enabled diagnostics):

09:38:31.170812 git.c:594               trace: exec: 'git-run' 'git fetch --all && git reset --hard @{u}' 09:38:31.170899 run-command.c:369       trace: run_command: 'git-run' 'git fetch --all && git reset --hard @{u}' 09:38:31.172819 run-command.c:369       trace: run_command: 'f() { "$@" && git submodule foreach --recursive "$@"; }; f' 'git fetch --all && git reset --hard @{u}' 09:38:31.173268 run-command.c:228       trace: exec: '/bin/sh' '-c' 'f() { "$@" && git submodule foreach --recursive "$@"; }; f "$@"' 'f() { "$@" && git submodule foreach --recursive "$@"; }; f' 'git fetch --all && git reset --hard @{u}' f() { "$@" && git submodule foreach --recursive "$@"; }; f: git fetch --all && git reset --hard @{u}: command not found fatal: while expanding alias 'run': 'f() { "$@" && git submodule foreach --recursive "$@"; }; f': no such file or directory 

how can alias work want?


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -