Dive deep into the world of Git repositories and learn how to initialize a Git repo using Visual Studio Code. This comprehensive guide provides an understanding of project files, revision history, and crucial tips for dealing with hidden files in macOS.
Key Insights
- Git repositories, or repos, contain all project files and the complete revision history.
- Creating a repository involves instructing Git to convert an ordinary folder of files into a repo, which leads to the formation of a .git subfolder for tracking changes.
- The .git subfolder is hidden in Unix-based operating systems like macOS and is not directly accessible. However, it can be made visible by pressing Cmd–Shift-Period(.) on macOS.
- To initialize a Git repo, the first step is to open a project folder in Visual Studio Code.
- The Source Control panel on the left of the window is then opened.
- Finally, in the Source Control panel, the Initialize Repository option is selected to complete the process.
Explore in-depth, the nuts and bolts of Git repositories—understanding what they contain, how to initialize one, navigate them using Visual Studio Code, and effectively utilize Source Control panel.
This exercise is excerpted from Noble Desktop’s Git & GitHub training materials and is compatible with updates through 2022. To continue learning web development with hands-on training, check out our coding bootcamps in NYC and live online.
Git Repositories
A Git repository (or repo for short) contains all of the project files and the entire revision history. You’ll take an ordinary folder of files (such as a website’s root folder), and tell Git to make it a repository. This creates a .Git subfolder, which contains all of the Git metadata for tracking changes.
On Unix-based operating systems such as macOS, files and folders that start with a period (.) are hidden, so you will not see the .Git folder in the macOS Finder unless you show hidden files, but it’s there. You won’t ever need to go into the .Git folder, so don’t worry about not being able to see it.
TIP: On macOS you can show or hide invisible files by hitting Cmd–Shift-Period(.)
Initialize a Git Repo
-
Open a project folder in Visual Studio Code.
You can do this by going to File > Open (Mac) or File > Open Folder (Windows), navigate to the folder, select it, and hit Open (Mac) or Select Folder (Windows).
- Open the Source Control panel
on the left of the window.
In the Source Control panel
click Initialize Repository.