git命令 add -a和add .和add -u 的区别

总结:

  • git add -a 所有的更改操作–新建,更改,删除;
  • git add . 只包括 新建 ,修改操作;无删除;
  • git add -u 只包括修改,删除操作,无新建;

示例:

git init
echo Change me > change-me
echo Delete me > delete-me
git add change-me delete-me
git commit -m initial

echo OK >> change-me
rm delete-me
echo Add me > add-me

git status
# Changed but not updated:
#   modified:   change-me
#   deleted:    delete-me
# Untracked files:
#   add-me

git add .
git status

# Changes to be committed:
#   new file:   add-me
#   modified:   change-me
# Changed but not updated:
#   deleted:    delete-me

git reset

git add -u
git status

# Changes to be committed:
#   modified:   change-me
#   deleted:    delete-me
# Untracked files:
#   add-me

git reset

git add -A
git status

# Changes to be committed:
#   new file:   add-me
#   modified:   change-me
#   deleted:    delete-me

Summary:

  • git add -Astages All
  • git add .stages new and modified, without deleted
  • git add -ustages modified and deleted, without new

参考:http://stackoverflow.com/questions/572549/difference-of-git-add-a-and-git-add

    原文作者:cocoajin
    原文地址: https://www.cnblogs.com/cocoajin/p/3324010.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞