Git add and commit in one command

后端 未结 27 2371
旧巷少年郎
旧巷少年郎 2020-11-28 00:28

Is there any way I can do

git add -A
git commit -m \"commit message\"

in one command?

I seem to be doing those two commands a lot,

27条回答
  •  -上瘾入骨i
    2020-11-28 00:31

    I use the following (both are work in progress, so I'll try to remember to update this):

    # Add All and Commit
      aac = !echo "Enter commit message:" && read MSG && echo "" && echo "Status before chagnes:" && echo "======================" && git status && echo "" && echo "Adding all..." && echo "=============" && git add . && echo "" && echo "Committing..." && echo "=============" && git commit -m \"$MSG\" && echo "" && echo "New status:" && echo "===========" && git status
    
    # Add All and Commit with bumpted Version number
      aacv = !echo "Status before chagnes:" && echo "======================" && git status && echo "" && echo "Adding all..." && echo "=============" && git add . && echo "" && echo "Committing..." && echo "=============" && git commit -m \"Bumped to version $(head -n 1 VERSION)\" && echo "" && echo "New status:" && echo "===========" && git status
    

    With the echo "Enter commit message:" && read MSG part inspired by Sojan V Jose

    I'd love to get an if else statement in there so I can get aacv to ask me if I want to deploy when it's done and do that for me if I type 'y', but I guess I should put that in my .zshrc file

提交回复
热议问题