1

What is the difference between the following commands?

  • git add .
  • git add -A
  • git add -u

I tried to execute them, and they create the same results.

1
  • Couldn't find that duplicate before. Commented Jan 31, 2018 at 8:23

1 Answer 1

1

git help add

   -A, --all, --no-ignore-removal
       Update the index not only where the working tree has a file matching <pathspec> but also where the index already has an
       entry. This adds, modifies, and removes index entries to match the working tree.

       If no <pathspec> is given, the current version of Git defaults to "."; in other words, update all files in the current
       directory and its subdirectories. This default will change in a future version of Git, hence the form without <pathspec>
       should not be used.

   -u, --update
       Update the index just where it already has an entry matching <pathspec>. This removes as well as modifies index entries to
       match the working tree, but adds no new files.

       If no <pathspec> is given, the current version of Git defaults to "."; in other words, update all tracked files in the
       current directory and its subdirectories. This default will change in a future version of Git, hence the form without
       <pathspec> should not be used.
  • . is implied by both -A and -u if no <pathspec> is given (which is the case in your question).
  • -A will stage changes, removed files, and added files.
  • -u will stage changes and removed files, but not added files.
Sign up to request clarification or add additional context in comments.

1 Comment

Isn't there a difference between Git 2.0 and earlier versions, Git 1.X?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.