Is git commit -am redundant, if I do git add before?

前端 未结 5 947
忘了有多久
忘了有多久 2021-01-30 13:41

Is it redundant to run git add . and then git commit -am \"commit message\"?

Can I just run git add . and then git commit -m

5条回答
  •  臣服心动
    2021-01-30 14:03

    The -a switch tells git to stage the modified files for adding - it stands for 'all' not 'add'. If you wan't the content in a new file to be added to git then you must add it using git add before you commit it.

    If you have already done a git add . then it has already added all files in the current directory i.e. both new and modified files. Hence you don't need a -a switch to stage content again. So you can rightly just follow it up with a git -m "msg"

提交回复
热议问题