Initializing a repository
We're about to initialize our first repository! I hope you didn't close the terminal yet, because we're going to use it for something important.
The command to create a new repository is . This command creates a new empty repository in the current directory. Run the following command in your terminal to initialize the new repository:
Run the git init command in the terminal.
If everything went according to plan, you should see something like this as the output of the command:
Initialized empty Git repository in .../.git/This means that changes in our project can now be tracked by Git.
The repository itself is located in a hidden directory named .git. Because it's hidden, you won't see it in the file explorer by default. However, you can see it in the terminal by running the command with the -Force-a option. Keep in mind that if something happens to the .git
directory, the repository will be corrupted.
Everything else in the root directory of the project is usually called the (or the working directory). Think of the directories and files in your project branching out like limbs on a tree—that's why Git uses the word tree here. It's the place where you do all the work, create and edit files, etc. The files in the working tree can differ from what you saved in the repository. For example, you can have a file in the working tree that is not yet in the repository. You can tell Git to either save the changes in the repository or discard them.
Take the course as it was meant to be taken: bite-sized progression, focused linear order, gradually unlock Gitopedia entries. Continue with real Git in VS Code/Cursor/Antigravity/Windsurf at any time.
but requires sign-in