You’ve just created your first local Git repository, but it’s currently empty.
To get started, add some files to the repository or create a new file using your favorite text editor. After creating the file, save it or move it to the folder where you initialized your Git repository.
If you’re interested in learning how to create a new file with a text editor, check out our HTML tutorial on HTML Editors.
For this example, I’ll use a simple HTML file, like this:
<!DOCTYPE html> <html> <head> <title>Hello World!</title> </head> <body> <h1>Hello world!</h1> <p>This is the first file in my new Git Repo.</p> </body> </html> |
Save this file to our new folder as index.html
.
Now, let’s go back to the terminal and list the files in our current working directory.
[user@localhost] $
|
ls |
The ls
command will display the files in the directory, and you’ll see that index.html
is there.
Next, let’s check the Git status to see if the file is part of our repository:
[user@localhost] $ |
git status On branch master
No commits yet
Untracked files: (use “git add …” to include in what will be committed) index.html nothing added to commit but untracked files present (use “git add” to track) |
Now, Git recognizes the file, but it hasn’t been added to our repository yet!
Files in your Git repository can be in one of two states:
When you initially add files to an empty repository, they are all untracked. To have Git track these files, you need to stage them by adding them to the staging area.
We’ll discuss the staging area in the next chapter.