The first step in working with git is to create a new git repository.We can create a new git repository by either
- copying an existing repository
- initializing a new repository
Copying an existing repository
for copying an existing repository we use the git clone command.To clone an existing repository from an existing location we use the command as:
git clone “url of the repository”
for example to clone a repository at the location http://www.testrepo.com/Temp we use the following command
git clone http://www.testrepo.com/Temp
The above command will copy the existing repository from “http://www.testrepo.com/Temp” to the local machine.The name of the new repository will be the same as the existing repository.
If we want to provide a different name for the cloned repository then we can pass the name of the repository as:
git clone http://www.testrepo.com/Temp NewRepository
Initialize a new repository
To initialize an existing directory as git repository we use:
git init
we execute the above command from within the directory which we want to initialize as git repository
Leave a Reply