Skip to content

Instantly share code, notes, and snippets.

@openhubdev
Last active January 21, 2022 12:40
Show Gist options
  • Save openhubdev/2f30ab78797e474f9265205d6c66abb9 to your computer and use it in GitHub Desktop.
Save openhubdev/2f30ab78797e474f9265205d6c66abb9 to your computer and use it in GitHub Desktop.
git add . vs git add -A vs git add -u

Summary:

git add -A stages all changes

git add . stages new files and modifications, without deletions (on the current directory and its subdirectories).

git add -u stages modifications and deletions, without new files

Detail:

The important point about git add . is that it looks at the working tree and adds all those paths to the staged changes if they are either changed or are new and not ignored, it does not stage any 'rm' actions.

git add -u looks at all the already tracked files and stages the changes to those files if they are different or if they have been removed. It does not add any new files, it only stages changes to already tracked files.

git add -A or git add --all is a handy shortcut for doing both of those. This adds, modifies, and removes index entries to match the working tree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment