What does the clone
command do? Is there any equivalent to it in svn?
What is the difference between
git remote add test git://github.c
git clone
:
Will physically download the files into your computer. It will take space from your computer. If the repo is 200Mb, then it will download that all and place it in the directory you cloned.
git remote add
:
Won't take space! It's more like a pointer! It doesn't increase your disk consumption. It just gets a snapshot of what branches are available and their git commit history I believe. It doesn't contain the actual file/folders of your project.
If you do:
git remote add TechLeadRepo git://github.com/user/test.git
then you haven't added anything to your computer. After you've added it in your remote branches then you're able to get a list of all branches on that remote by doing:
git fetch --all
upon fetching (or pulling), you download the files And then if you wanted to do get your colleague's feature22 branch into your local, you'd just do
git checkout -b myLocalFeature22 TechLeadRepo/feature22
Had you cloned his repo then you would have to go into that local repository's directory and simply just checkout
to your desired branch
git remote add
just creates an entry in your git config that specifies a name for a particular URL. You must have an existing git repo to use this.
git clone
creates a new git repository by copying an existing one located at the URI you specify.
These are functionally similar (try it!):
# git clone REMOTEURL foo
and:
# mkdir foo # cd foo # git init # git remote add origin REMOTEURL # git pull origin master # cd ..
Now there are minor differences, but fundamentally you probably won't notice them. As an exercise left to the reader, compare the .git/config's from each directory.
The clone
command creates a local copy of the repo you specified. remote add
adds a remote repo that you can either push to or pull from.
The svn equivalent of clone
is checkout
.