How to create a new git project

Zhao Li
3 min readSep 5, 2018

Problem

Before you can start using git, you need to create a git repository first.

A repository is where all of your project code is stored and accessed.

Solution

There are two common ways of creating a git repository. The method you choose depends if you are creating a brand new repository or if you are creating a clone of an existing repository.

Initializing

To initialize a brand new repository on your local development machine, you use the command git init.

$ mkdir my_project # create the directory for your project
$ cd my_project # the git command is executed within the project directory
my_project$ git init # initialize a git repository
Initialized empty Git repository in .../my_project/.git/

You have just created your git repository on your local development machine.

Cloning

To clone an existing repository on to your local development machine, you use the command git clone.

For this example, we will be cloning this git repository: https://github.com/django/django

$ git clone https://github.com/django/django.git
Cloning into 'django'...
remote: Counting objects: 420546, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 420546 (delta 0), reused 1 (delta 0), pack-reused 420540
Receiving objects: 100% (420546/420546), 176.36 MiB | 4.58…

--

--

Zhao Li
Zhao Li

No responses yet