How do you create local Git repository?
Answer
Your local repository can be created in two ways:
Create empty repository
When you start a new project, you usually want to create a new empty repository. This can be done by executing the following command from the command line:
git init
The command above will create the new repository in your current folder. You can also run the following command:
git init <NameOfYourRepository>
The command above will create the new repository in the folder <NameOfYourRepository>. The folder for the new repository will be created in your current folder.
Clone existing repository
When you join an existing project, you usually want to clone already existing repository. This can be done by executing the following command from the command line:
git clone <AddressToYourRepo>
The remote repository will be downloaded to your local computer as a local repository. The remote repository is often called Upstream, the local repository is called Downstream.
Related Git job interview questions
-
How do you get changes from the remote repository to your computer?
Git Source control Junior -
What is a difference between local and remote repository?
Git Source control Junior -
How do you send changes from local Git repository to remote repository?
Git Source control Junior -
What is a Git repository?
Git Source control Junior -
What is Git?
Git Source control Junior