How to Create a Git Repository: git init

Git Tips & Commands

Gain a thorough understanding of how a Git repository works and learn how to initialize one using terminal commands. This knowledge is essential for a career in web development, data science, and more.

Key Insights

  • A Git repository, or repo, contains all of a project's files and the entire revision history.
  • To make a folder into a Git repository, you instruct Git to make it a repository, which creates a .git subfolder for tracking changes.
  • The .git subfolder might be hidden on Unix-based operating systems like macOS, but it can be viewed in some code editors.
  • To initialize a Git repo, navigate to the desired folder via terminal and enter the command "git init".
  • Knowledge of Git repositories is crucial in fields like web development, data science, Python programming, and web design.
  • There are a variety of coding courses and bootcamps available that offer hands-on learning and step-by-step instruction through real-world exercises.

Essential Git Commands

  • git status

    What's changed, staged, and untracked — your most-used command.

  • git diff

    See exactly what's different before staging.

  • git log

    Inspect commit history with --oneline or --graph for visualization.

  • git reset

    Undo staging or commits — careful with --hard.

A Git repository (or repo for short) contains all of the project les and the entire revision history. You’ll take an ordinary folder of les (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, les 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 les, but it’s there! You might be able to see it in some code editors.

TIP: On macOS you can show or hide invisible les by hitting Cmd–Shift-Period(.)

Initialize a Git Repo

  1. In your terminal (Terminal, Git Bash, or Windows Command Prompt), navigate to the folder you wish to make into a Git repo.

  2. Enter this command:

    Git init

Go Beyond Git

We offer the best coding courses and bootcamps for students at all levels of experience. Classes are hands-on and students receive workbooks with step-by-step instructions through exercises with real-world applications. Check out our programming courses now:

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.

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