DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 963,274 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for Don't use "git add ."
Jeferson 'Shin' Leite Borges
Jeferson 'Shin' Leite Borges

Posted on • Updated on

Don't use "git add ."

TL:DR

git add -A will stages all changes
git add . will stages new files and modifications, without deletions
git add -u stages modifications and deletions, without new files


Wait, this post is in English. So keep going!

I never put enough thought into the mentor I had. He was not the teacher, he was a guide in this world of web development, just pointing my focus and attention to learning the right thing. And I remember when he told me to avoid using git add . and instead use git add -A.

At that time, I never thought about it, I just assumed I was doing it wrong, until yesterday I was wondering why there are two ways to add files to the stage area.

When you add files with git add ., you are adding every single file in the current folder, or structure, or anything like that, It's ok, you can do that, you can even add git add file.js for example.

But if you want to add any deletion, update and all changes in the other directories, in this case, you should use add git add -A, this -A means ALL.

Another way is to update only the updated files, without any test file, or some experimental code, in this case, you can use git add -u, this -u means UPDATE.

Easy to remember, right?

(()=>{})()

Top comments (2)

Collapse
 
theluk profile image
Lukas Klinzing

git add -i

Collapse
 
shinspiegel profile image
Jeferson 'Shin' Leite Borges Author

I did read about it, but I didn't tried this. I'm curious about the "interactive mode" of these.

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.