Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Git creates a repository


May 25, 2021 Git


Table of contents


Git creates a repository

In this section we'll show you how to create a remote Git repository. You can use an existing directory as a Git repository or create an empty directory.

Using your current directory as a Git repository, we just need to initialize it.

git init

Use our designated directory as a Git repository.

git init newrepo

After initialization, a directory named .git appears in the current directory, where all the data and resources that Git needs are stored.

If there are several files in the current directory that you want to incorporate into version control, you need to tell Git to start tracking them with the git add command, and then commit:

$ git add *.c
$ git add README
$ git commit -m 'initial project version'

Clone from an existing warehouse

The command format for cloning the repository is:

git clone [url]

For example, to clone the Ruby-language Git code repository Grit, you can use the following command:

$ git clone git://github.com/schacon/grit.git

After executing this command, a directory named grit is created under the current directory, which contains a directory of .git that holds all downloaded version records.

If you want to define the project directory name you want to create yourself, you can specify the new name at the end of the command above:

$ git clone git://github.com/schacon/grit.git mygrit