What’s the difference between “git add -u” and “git add -A”?

Brief Answer:

git add -A is equal to git add . + git add -u


Explanation:

When you do a “git add .“, it adds all files (existing, modified and new) to the staging area but it does not remove files that have been deleted from the disk.

git add -u” only adds currently tracked files (which have been modified) to the staging area and also checks if they have been deleted (if yes, they are removed from staging area). This means that it does not stage new files.

Doing “git add -A” performs both of these steps, that is, stages your entire directory as it is.


Summary:

  • git add -A : Stages Everything
  • git add -u : Stages only Modified Files
  • git add . : Stages everything, without Deleted Files

Read the Documentation for more.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)