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

  • Home
  • SEARCH
  • 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 6720523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:13:20+00:00 2026-05-26T09:13:20+00:00

I try to commit and push in one command, typing something like: gm This

  • 0

I try to commit and push in one command, typing something like:

gm "This is my commit message"

Which would run:

git commit -am "This is my commit message" && git push

I’ve tried this function in my .bashrc:

function gm() {
     git commit -am $1 && git push
}

Which works, except for the fact that I can not type several words as commit message. I can run

gm My_Message

and it works fine, but if I type several words, like

gm This is my message

It will only run git commit -am "This" && git push. I tried using quotation marks but it returns an error. How should I configure this function to work?

  • 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-26T09:13:21+00:00Added an answer on May 26, 2026 at 9:13 am

    You need quotes around both the place calling the function and the git command.

    function gm() {
         git commit -am "$1" && git push
    }
    
    gm "This is my message"
    

    An alternative approach is:

    function gm() {
         git commit -am "$*" && git push
    }
    
    gm This is my message
    

    But this will mean that:

    gm This commit  has double  spaced sections.\t And a tab, \
    and a new line
    

    (Where \t is actually a tab)
    will give the commit message of:

    This commit has double spaced sections. And a tab, and a new line
    

    So all the white space is collapsed.

    Also, if you want to enter a more complicated and complete commit message, you might want to you $EDITOR and omit -m entirely.

    Also, you aren’t really using the power of distributed version control if you immediately push every commit.

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

Sidebar

Related Questions

What would possibly cause a 'git push' to try and commit to two branches?
I need the ability to run an arbitrary command when I try and commit
I keep getting this error when I try to commit a group of executed
Using Subversion I try to commit with: svn ci dir/filename And I get this:
I try to convince my coworkers to leave svn and switch to git. One
The git central repository to which I need to commit is configured using SSH
I've run into a problem when I try to push only the new files
When I try to commit SVN reports about 10 old directories as missing. I've
I commit all my files into bitbucket. i try check in,revert file i deleted
Try loading this normal .jpg file in Internet Explorer 6.0. I get an error

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.