Your First Repository
A repository is a project folder that Git watches. This lesson makes one and watches a first file.
Start a repository
Git prints the folder it made. Your folder will show your own path.
$ git initAsk Git what it sees
The folder is empty, so Git says there is nothing to save yet.
$ git statusAdd a file, ask again
Create a file called notes.txt with three lines, then ask Git again.
$ git statusExample
$ git init
$ git statusKey points
- Make a folder for the project first.
- The command git init turns the folder into a repository.
- Git stores its records in a hidden folder called .git.
- You never edit the .git folder by hand.
- The word branch names the line of work you are on.
- The first branch is called main.
- A new file starts as untracked, which means Git sees it but does not watch it yet.
- The status command reports what Git sees.
Here, one command turns the folder into a repository. Status reports the branch name, main, and says no snapshots exist yet. The words “No commits yet” mean the history is empty.
Note
Run every command in this course inside the project folder.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
What does git init do?