Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get remote repository Git

I am almost newby in Git and just read Git book from the official site. I try understand difference between next cases.

git init Project
git remote add Project [some-url]

and

git clone [some-url]

And what is a preferable approach?

like image 782
Ray Avatar asked Sep 18 '13 08:09

Ray


2 Answers

git clone [something] is the equivalent to:

git init Project
git remote add origin [some-url]
git pull origin master

It's a little strange to call your remote Project, but perhaps that was a typo. Either way, you can specify -o to name the remote something else when cloning, from the man page:

Instead of using the remote name origin to keep track of the upstream repository, use .

like image 105
juco Avatar answered Sep 28 '22 06:09

juco


There is no question of preference. These are commands for 2 entirely different purposes.

git init Project
git remote add Project [some-url]

git init initializes a directory as a Git repository

This is used when you are starting work on a new project, not continuing work on an existing project under version control.

git clone [some-url]

git clone copies a git repository so you can add to it

This would clone an existing repository off the remote to your machine, so that you can work on it.

Links to help you out:
* git init
* git clone

like image 38
abhshkdz Avatar answered Sep 28 '22 06:09

abhshkdz