Create a New Local Git Repository (Initialize Repository)

Git Tutorial

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.

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.

Resolve a Merge Conflict

  1. Identify Conflicts

    git status shows files with conflicts after a failed merge.

  2. Open the Files

    Look for <<<<<< / ====== / >>>>>> markers — your changes vs theirs.

  3. Edit & Stage

    Pick the right code, remove markers, git add the file.

  4. Complete the Merge

    git commit finalizes the merge with the resolved content.

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(.)

Full-Stack Web Development Certificate: Live & Hands-on, In NYC or Online, 0% Financing, 1-on-1 Mentoring, Free Retake, Job Prep. Named a Top Bootcamp by Forbes, Fortune, & Time Out. Noble Desktop. Learn More.

Initialize a Git Repo

  1. 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).

  2. Open the Source Control panel on the left of the window.
  3. In the Source Control panel click Initialize Repository.

Learn more in these courses

How to Learn Git

Master Git with hands-on training. Git is a free, open-source version control system that allows developers to track the changes they make to code.

Yelp Facebook LinkedIn YouTube Twitter Instagram