3

I'm trying to add the following alias using shell function

scommit = "!f() { git submodule foreach -q --recursive 'git commit -a || :' ; git commit -am \" Update submodule \";}; f"

But when I run it in Git bash (on Windows)

git config --local alias.scommit "!f() { git submodule foreach -q --recursive 'git commit -a || :' ; git commit -am "" Update submodule "";}; f"

I got output

git config --local alias.scommit "fit fetch upstream() { git submodule foreach -q --recursive 'git commit -a || :' ; git commit -am "" Update submodule "";}; f"

and of course it doesn't work because

Expansion of alias 'scommit' failed; 'fit' is not a git command

Also I tried to run it in PowerShell but it shows usage: git config [] …

When I add it to .git/config manually then it works.

How can I add this alias using git bash/ command line / PowerShell ? Why does it transforms to fit fetch upstream()?

1 Answer 1

2
+50

I just tested, on Windows 10, with Git 2.18:

git config --local alias.scommit '!f() { git submodule foreach -q --recursive "git commit -a" || : ; git commit -am "Update submodule";}; f'

The idea is to inverse the quotes: strong quotes (') at the outside of the alias, weak quotes (") inside.

That avoids for ! to be interpreted as extended a command from history (as you can see here) (although set +o histexpand before the git config command could have helped)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.