Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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 .

If you are going to work on a new project(for you) which is actually an existing project then you have to download that project. In terminal you can download it by typing

    git clone <url>

and work on this project and then push the updates to remote.

And, If you are going to create a new project of your own. Then create a remote repository and follow these simple steps. You will be asked to give your github username and password while adding to remote origin and then push the changes. If you have added README remote then you have to pull changes

    git pull origin <branchname(eg:master)>

and then push your local changes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top