DEV Community

Cover image for Quick Guide: Git Add and the A, U, R, D, M file markers
Bridget Amana
Bridget Amana

Posted on

Quick Guide: Git Add and the A, U, R, D, M file markers

So, I've been diving into open source projects recently, and naturally, I've been getting more familiar with Git. You know, Git is that tool that helps us keep track of changes in our code, making it super easy to collaborate with others. As I've been using Git more, I’ve come across some letters that pop up close to your file name in vscode “A, U, R, D, and M”.

Image description

First, what does git add do?

Before we jump into those letters, let’s quickly talk about what happens when you use git add. When you're working on a project and make changes to your files, Git doesn’t automatically know you want to include those changes in your next snapshot (or "commit"). So, you use git add to tell Git, "Hey, I want to include these changes in my next commit."

Now, after adding your changes you might see some letters next to the files you’ve modified. That’s where A, U, R, D, and M come into play.

What Do the Letters Mean?

A for Added:
What It Means: If you see an ‘A’ next to a file, it means that this file is new. You’ve added it to your project, and Git now knows about it and will include it in the next commit. Imagine you just created a new file—git add lets Git track it, and ‘A’ is the label that tells you it’s been added.

M for Modified:
What It Means: The ‘M’ stands for modified. This appears when you’ve made changes to a file that Git was already tracking.

R for Renamed:
What It Means: The ‘R’ pops up when you rename a file in your project. Let’s say you have a file called styles.css and you rename it to global_styles.css. When you run git add, Git will notice the name change and mark it with an ‘R’. It’s basically Git’s way of keeping track of the fact that this is the same file, just with a new name.

U for Untracked:
What It Means: When you see a ‘U’ next to a file, it indicates that the file is untracked. This means the file is new and hasn't been added to the repository yet. Git knows the file exists but isn't tracking it yet. You’ll need to use git add if you want to start tracking the changes to this file.

D for Deleted:
What It Means: The letter ‘D’ appears next to a file when that file has been deleted from your working directory. This indicates that the file was previously tracked by Git, but you have removed it. The ‘D’ shows up after you run git status or git diff, signifying that this file will be deleted in the next commit.

So, there you have it! Next time you run git add and see those letters, you’ll know exactly what they mean. These are just some of the letters you might see. There are others that you may encounter as you continue working with Git, especially in more complex situations like resolving merge conflicts. But these are the ones I’ve gotten to know well, and I hope this helps you get more comfortable with them too!
Happy coding!

Top comments (0)