Getting Started Git Basics Init

Init

Understand what git init does.

git init creates a new Git repository in an existing directory.

It is the usual starting point when you already have a project folder on your machine and want Git to begin tracking it.

What git init does

When you run git init, Git sets up the repository metadata it needs in that directory.

That usually means:

  • Creating the hidden .git directory.
  • Preparing the repository so Git can track commits, branches, and other history data.
  • Turning a normal folder into a Git repository.

It does not automatically create a remote, download history, or publish anything online.

When to use git init

Use git init when:

  • You started a project locally and want to begin tracking it with Git.
  • You received a folder of files that is not already a Git repository.
  • You want to create a brand new repository before making the first commit.

If the repository already exists somewhere else, you usually want clone instead.

Clone vs Init

Both commands create a usable local repository, but they solve different problems.

  • git init creates a new repository from the directory you already have.
  • Clone copies an existing repository, including its history and remote information.

In short, use git init to start a repository. Use clone to copy one that already exists.

What happens next

After initializing a repository, common next steps are:

  1. Review which files are in your worktree.
  2. Stage the files you want to include first.
  3. Create the first commit.
  4. Optionally add a remote later if you want to push the repository somewhere else.

Once a folder has been initialized as a Git repository, GitComet can open it and show its history, branches, and file state just like any other local repository.

Documentation

Search

move open Esc close

Browse the docs or start typing to filter results.