Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6082257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:16:09+00:00 2026-05-23T11:16:09+00:00

I have a series of commands that I run before committing a git project

  • 0

I have a series of commands that I run before committing a git project so I’ve put it in a bash script. At the end I have a block that does the commit:

if [ -z $1 ]; then git commit -a -m "no message"; else; git commit -a -m $1; fi

with the expectation that the message is passed to the script

$ ./dostuff_then_commit "my message"

When I do this, I get that

fatal: Paths with -a does not make sense.

because $1 has been defined but the message is not passed correctly? Can anyone see the problem and/or suggest a solution? Thanks SO.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:16:09+00:00Added an answer on May 23, 2026 at 11:16 am

    If the message contains spaces, it will expand to multiple parameters to git commit. (Notice the quoting in the other case.) Quote it:

    if [ -z "$1" ]; then
        git commit -a -m "no message"
    else
        git commit -a -m "$1"
    fi
    

    A couple of addenda:

    • I also quoted the one in the [], for a slightly different reason: if the commit message were empty, you would get a missing parameter diagnostic from [. Again, quoting it avoids this. (You might instead want to catch that and make the user enter a real commit message, although if it were that necessary you’d probably get a bunch of asdfzxcv commit messages….)

    • The error message you’re getting is specifically because the first word of the commit message is taken as the commit message and the rest are passed as specific filenames to commit; this, as the error message states, makes no sense when telling git to commit everything (-a).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bash script that executes a series of commands. One of them
I have a whole series of commands that I need to run on login,
I have a series of commands (calls to bash shell functions really) that compute
I have series of curl commands that I want to translate into straight up
Is there a series of commands that does ls then removes backup files? I
I have a perl script that runs a series of batch scripts for regression
I have an import script which runs a series of commands to get things
I have a series of commands that check whether a url looks something like
I have a series of logging breakpoints in Xcode4 that I'm using to selectively
I have a series of divs that slide down using -webkit-transform from a negative

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.