Reputation: 1983
I'm trying to write an alias for git that will accept the branch name and checkout to it in each submodule recursively. It's expected that some submodules may not have this branch, so they'll be skipped.
I tried this solution:
[alias]
subco = "!f() { git submodule foreach 'git checkout $1 || true'; }; f"
Bit it gives me error, $1 - is not typed correctly.
Entering 'Services/Payment'
error: pathspec 'git' did not match any file(s) known to git.
error: pathspec 'checkout' did not match any file(s) known to git.
error: pathspec '$1' did not match any file(s) known to git.
error: pathspec '||' did not match any file(s) known to git.
error: pathspec 'true' did not match any file(s) known to git.
I tried to put $1 in quotes, that doesn't help, ant suggestions?
Upvotes: 1
Views: 140
Reputation: 1983
Found mistake, input $1 should be outside the quotes:
[alias]
subco = "!f() { git submodule foreach 'git checkout '$1' || true'; }; f"
Upvotes: 1