Tracking Files: How to Use git add for Version Control
Learn how to create files and use git add to move them into the staging area. Master the first step in creating a permanent snapshot of your project work.

Previously in this course, we covered the conceptual Understanding the Git Lifecycle: Staging Area & Working Directory. Now that you understand the "why" behind the staging area, this lesson focuses on the "how": using the git add command to move your work from the working directory into the staging area to begin tracking your files.
The Role of Staging in Your Workflow
In Git, "tracking" a file means telling the version control system that it should watch this file for future changes. Before you create a permanent record (a commit), you must place your files into the staging area.
Think of the staging area as a "pre-commit" workspace. It allows you to selectively choose which file modifications are ready to be saved, giving you granular control over what goes into your project history.
Practical Example: Tracking a New File
Let’s advance our running project. Assume we have already initialized our repository as taught in Initializing a Repository: Start Your Git Project Today.
-
Create a file: Open your terminal in your project directory and create a new file named
notes.txt.Bashtouch notes.txt -
Check the status: Use
git statusto see how Git views this new file.Bashgit statusYou will see
notes.txtlisted under "Untracked files." This means Git sees the file on your disk, but it isn't part of your project's version history yet. -
Stage the file: Use the
git addcommand to move the file into the staging area.Bashgit add notes.txt -
Verify the change: Run
git statusagain.Bashgit statusNow,
notes.txtappears under "Changes to be committed." It is officially being tracked.
Hands-on Exercise
To build your working competence, try this sequence in your own terminal:
- Create a file named
README.mdusingecho "My Project" > README.md. - Run
git statusand confirm it is "Untracked." - Run
git add README.mdto stage it. - Run
git statusone last time to confirm it has moved to the "Changes to be committed" section.
Common Pitfalls
- Forgetting to add new files: A common mistake is assuming that because a file exists in the directory, Git is automatically tracking it. You must explicitly
git addevery new file. - Adding the wrong files: If you accidentally add a file you didn't mean to (like a temporary log or system file), don't panic. We will cover how to "unstage" files in a later lesson.
- Over-adding: Beginners often use
git add .to add every single file in a folder. While convenient, it is better to be explicit (e.g.,git add filename) as you learn, so you don't accidentally include sensitive files or build artifacts in your commit.
Frequently Asked Questions
Does git add save the file to the repository?
No. It only moves the file to the staging area. The file is not saved to the project history until you perform a git commit.
Can I use git add on files I have already added?
Yes. If you modify a file that is already being tracked, you must run git add again to stage those new changes before committing them.
What happens if I edit a file after I've already staged it?
The version you staged remains in the staging area, but your new edits in the working directory remain unstaged. You would need to run git add again to include the latest edits in the next commit.
Recap
Tracking files is the bridge between your local edits and your permanent project history. By using git add, you move files from the untracked state into the staging area, effectively telling Git: "I am ready for these changes to be part of the next snapshot."
Up next: We will take these staged files and finalize them in our history by Creating Your First Commit.
Work with me

VPS Server Setup, Deployment & Hardening
Get your app live on a fast, secure server — properly configured, hardened, and deployment-ready. No more wrestling with the command line.

AI Chatbot & LLM Integration for Your App or Website
Add a smart AI chatbot or LLM feature to your product — trained on your content, integrated into your stack, and shipped by an AI-native engineer.

