What is a New File?
A new file is any file you’ve added or copied into your project
folder, but haven’t yet told Git to track.
Here are the key points to understand:
- Create a new file using a text editor or by copying it into the folder.
- Use ls to list all files in the current directory.
- Run git status to see which files Git is tracking (and which it isn’t).
- Learn the difference between untracked files (new to Git) and tracked files (already added to Git).
Create a New File
Your new Git repository is currently empty.
Let’s add your first file! Open your favorite text editor, create a
new file, and save it inside your project folder.
If you’re not sure how to create a file, check out our HTML Editors
guide.
For this example, we’ll create a basic HTML file:
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<p>This is the first file in my new Git
repository.</p>
</body>
</html>
I added:
lang="en" for better accessibility.
<meta charset="UTF-8"> for proper character encoding.
<meta name="viewport"...> for responsive design.
View Files in Your Project Folder
To check which files are inside your project directory, you can use
the ls command:
Example:
ls
index.html
The ls command displays all files and folders in your current
location.
In this example, you should see index.html listed in the
output.
Check File Status with git status
After creating your new file, check whether Git is tracking
it:
Example:
git status
Output:
vbnet
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what
will be committed)
index.html
nothing added to commit but untracked files present (use "git add" to track)
In this output, Git detects index.html in your project
folder, but marks it as untracked — meaning it hasn't yet been
staged to the repository.
What is an Untracked File?
An untracked file is a file in your project directory that Git
isn’t monitoring yet.
These are typically new files you’ve created or copied into the
folder, but haven’t yet added to Git’s tracking system.
What is a Tracked File?
A tracked file is a file that Git is actively monitoring for
changes.
To turn an untracked file into a tracked file, you need to add it
to the staging area (we’ll explain how to do this in the next
section).
Troubleshooting
File not showing up with ls:
Check that you actually saved the file in the intended
folder.
Run pwd to confirm you’re in the correct directory.
File missing from git status:
Ensure you’re inside the right project folder and that the file
has been saved.
More topic in Git