Reputation: 4697
New to Git. Running it on windows. When I run this command in a .sh file (from a BASH shell), it works:
cd /c/SomeDir && git commit -a -m "commit comment"
I want to do that with a variable comment, so I want to call: C:\Program Files\Git\usr\bin\bash.exe and pass the above command (2 commands chained) as the parameter (with a different comment each time).
It doesn't work; looking for ideas...
Clarification: I'm using a utility to run commands, but basically, this is all I want to call:
Executable:
C:\Program Files\Git\usr\bin\bash.exe
Parameters (if test.sh has everything it needs but the comment):
bash /c/somewhere/test.sh "my comment"
Alternatively, the Parameters could simply be:
cd /c/MyRepoDir && git commit -a -m "my comment"
Further: Even after creating a .sh script, calling bash, and running that script, I still get an error, "Paths with -a does not make sense." Then, even after doing what's recommended here (same commands), I STILL get the same error.
Upvotes: 5
Views: 13435
Reputation: 694
try putting $1 in to reference the first parameter
cd /c/SomeDir && git commit -a -m "$1"
so myScript.sh contains your line, then
bash myScript.sh "this is my commit message"
an alternative to this approach from using cd is pushd and popd
#!/bin/bash
pushd mygitdir
git commit -a -m "$1"
popd
Upvotes: 3