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

前端 未结 5 998
忘了有多久
忘了有多久 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:09

    Actually, git commit -a is not always redundant, as it also removing files! For example you have two files: One file is tracked the other not. Now you want to delete the tracked (everywhere) and add the not tracked.

    So you remove the tracked file. If you then use only git add . and then git commit it will track the new but won't delete the old file in the repository.

    So you either execute git rm … or using git commit -a.

提交回复
热议问题