The difference between git add – A and git add

Time:2020-11-22

Two methods of GIT branching and merging

Git add – A and git add. Git add – u are similar in function, but there are still some differences

git add . : he will monitor the status tree of the workspace, which will be used to commit all changes in the work to the staging area, including modified and new files, but not deleted files.

git add -u : he only monitors the files that have been added (i.e. tracked files), and he will submit the modified files to the temporary storage area. Add – U does not commit a new file (untracked file). (GIT add — short for update)

git add -A : is the combination of the above two functions

The following is a specific operation example to facilitate better understanding (GIT version 1. X):


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 – a submits all changes
  • ·Git add – U submits modified and deleted files, excluding new files
  • ·Git add. Submit new and modified files, excluding deleted files

Git version will be different:

Git Version 1.x: 

Git Version 2.x: 

 

This article on the difference between git add – A and git add. Detailed explanation of the article introduced here, more relevant git add – A and git add. Content please search the previous articles of developeppaer or continue to browse the related articles below. I hope you can support developeppaer more in the future!