Git add and commit in one command

后端 未结 27 2381
旧巷少年郎
旧巷少年郎 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:47

    git commit -am "message"
    

    is an easy way to tell git to delete files you have deleted, but I generally don't recommend such catch-all workflows. Git commits should in best practice be fairly atomic and only affect a few files.

    git add .
    git commit -m "message"
    

    is an easy way to add all files new or modified. Also, the catch-all qualification applies. The above commands will not delete files deleted without the git rm command.

    git add app
    git commit -m "message"
    

    is an easy way to add all files to the index from a single dir, in this case the app dir.

提交回复
热议问题