Sandbox
Sandbox

Reputation: 8188

What happens in Git when adding origin?

What does Git exactly do when we add an origin?

Is it like saying we are creating a new repository? How different it is from push?

Upvotes: 0

Views: 67

Answers (1)

bredikhin
bredikhin

Reputation: 9045

Traditionally, origin is just the default name assigned to a remote repository when you clone it:

git clone [email protected]:some/repo.git

will result in having

origin  [email protected]:some/repo.git (fetch)
origin  [email protected]:some/repo.git (push)

as the output of git remote -v.

Alternatively, if you want to be able to push/pull to/from another remote repository, you can do:

git remote add [email protected]:another/repo.git whatever

and receive

origin  [email protected]:some/repo.git (fetch)
origin  [email protected]:some/repo.git (push)
whatever    [email protected]:another/repo.git (fetch)
whatever    [email protected]:another/repo.git (push)

from git remote -v.

After that you'll be able to do both git push origin master and git push whatever master.

Upvotes: 3

Related Questions