I'm doing a git clone
on a project following the instructions. But, do I need to do an init
in the directory beforehand?
git clone is used to create a copy of an existing repository. Internally, git clone first calls git init to create a new repository. It then copies the data from the existing repository, and checks out a new set of working files.
git init is for every project Almost correct. git init is used to start using git on a project that's not under git. For projects that are already under git you use git clone .
From your repository page on GitHub, click the green button labeled Clone or download, and in the “Clone with HTTPs” section, copy the URL for your repository. Next, on your local machine, open your bash shell and change your current working directory to the location where you would like to clone your repository.
git clone
is basically a combination of:
git init
(create the local repository)git remote add
(add the URL to that repository)git fetch
(fetch all branches from that URL to your local repository)git checkout
(create all the files of the main branch in your working tree)Therefore, no, you don't have to do a git init
, because it is already done by git clone
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With