The Git repository is where the metadata and object database is stored for a project. This is where the project is pulled from in order to get a local clone of a repository on a local system.
There are two options for obtaining a Git repository. The first is for when a directory already exists and there is the need to initialize a Git repository. The second is cloning a repository that already exists.
To clone an existing repository (for example, to contribute to) then run the following command:
$ git clone git://location/of/git/repository.git
Note that the command is git clone as opposed to git checkout as it might be for a version control system similar to CVS and SVN. This is because Git receives a copy of every file in the project's entire history, as opposed to only the most recent files as with other version control systems.
The above command creates a directory where the name is the last component of the URL, but with any .git suffix removed. However, the clone command can use any other name simply by appending the desired directory name to the end:
$ git clone git://location/of/git/repository.git my_git_repo
Finally, even though this command uses the git:// protocol, it is also possible to use http:// or https:// as appropriate.
To create a new Git repository ready to create data for, first navigate to the project's directory and type:
$ git init
This creates a skeleton of a Git repository, containing all the necessary files ready for content to be created and added.
Now that either a skeleton Git repository is set up or a local clone copied and ready on the local system it is time to look at the rest of the Git cycle.
This image shows how the Git cycle works and will be explained in further detail in the following sections.