DEV Community

Sebastian Korotkiewicz
Sebastian Korotkiewicz

Posted on

5 2

git add . vs git add -A

Both of these will stage all files, including new files (which git commit -a misses) and deleted files.

The difference is that git add -A also stages files in higher directories that still belong to the same git repository. Here's an example:

/my-repo
  .git/
  subfolder/
    nestedfile.txt
  rootfile.txt

If your current working directory is /my-repo, and that's the root of this git repo (thus the .git/ folder), these two commands will do the same thing.

But if you rm rootfile.txt, then cd subfolder, git add . will not stage the change that ../rootfile.txt has been deleted, because git add . only affects the current directory and subdirectories. git add -A, on the other hand, will stage this change.

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay