Git add and commit in one command

后端 未结 27 2250
旧巷少年郎
旧巷少年郎 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条回答
  • 2020-11-28 00:40

    I use this git alias:

    git config --global alias.cam '!git commit -a -m '

    So, instead of call

    git add -A && git commit -m "this is a great commit"

    I just do:

    git cam "this is a great commit"

    0 讨论(0)
  • 2020-11-28 00:41

    If you type:

    git config --global alias.a '!git add -A && git commit -m'
    

    once, you will just need to type

    git a
    

    every time:

    git a 'your comment'
    
    0 讨论(0)
  • 2020-11-28 00:41

    I do a shell

    #!/bin/sh
    
    clear
    
    git add -A 
    git commit -a -m "'$*'"
    

    save for example git.sh and later call:

    sh git.sh your commit message
    
    0 讨论(0)
  • 2020-11-28 00:41
    1. type git add . && git commit -am and enter
    2. type historyand enter
    3. remember the number for the above command, say the number is 543
    4. From now on, for every commit type !543 "your comment here" i.e. exclamatory mark+number and a space and your comment.
    0 讨论(0)
  • 2020-11-28 00:42

    To keep it in one line use:

    git add . && git commit -am "comment"
    

    This line will add and commit all changed and added files to repository.

    0 讨论(0)
  • 2020-11-28 00:46

    Just use:

    git commit -m "message" .     
    

    Notice the "." at the end... which can also be a path to a file/directory

    0 讨论(0)
提交回复
热议问题