Git FAQ
Frequently asked questions around Git and Version Control.
Git FAQ featured image

How to Create a New Repository in Git

When you're starting a new coding project (or joining an existing one) the first thing to do is create (or clone) the project's Git repository.

In this short article, we'll look at how to create a brand new Git repository as well as how to join an existing project by downloading its Git repository.

The Git Cheat Sheet

No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!


Creating a Brand New Repository

If you want to start a new coding project on your computer, there are a couple of easy steps to follow if you want to put this project under version control with Git:

#1: Create a folder for this project on your local hard drive
$ mkdir my-project

#2: change into this folder
$ cd my-project

#3: initialize a new, empty Git repository here
$ git init

...after having written some code + created some files...
#4: add all changes to the next (= first) commit
$ git add .

#5: create this first commit
$ git commit -m "Initial commit"

This set of commands leaves you with a new Git repository, your first few code files already added in a first commit.

In case you are using the Tower Git client, you can simply drag and drop your project folder - and then create your first commit with a couple of simple clicks:

Cloning an Existing Repository

If you want to join an existing project that has already been started by someone else, you have to clone it. Cloning a repository from a remote server means downloading it to your computer so you can work on the project. Here's a quick overview of how to do that:
(Note: I suppose you already have an account for the corresponding code hosting platform - like GitHub, GitLab, Bitbucket... - and the project owner has given you access to the repository!)

#1: move to the location where you want to download the project
$ cd my-projects

#2: download the project by cloning it
$ git clone https://github.com/gittower/git-crash-course.git

You might then have to provide your authentication details - and will then have the complete project, including all of its history, on your computer and can start contributing to the project.

In case you are using the Tower Git client, cloning a project is very easy: after you've connected your GitHub / GitLab / Bitbucket / ... account to Tower, you don't have to worry about usernames, passwords, or tokens anymore. You'll have access to all of your repositories on the remote server - and can clone any of them with just a single click:

Learn More

About Us

As the makers of Tower, the best Git client for Mac and Windows, we help over 100,000 users in companies like Apple, Google, Amazon, Twitter, and Ebay get the most out of Git.

Just like with Tower, our mission with this platform is to help people become better professionals.

That's why we provide our guides, videos, and cheat sheets (about version control with Git and lots of other topics) for free.