Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the meaning of 'origin' in 'git push origin master'

Tags:

git

When I run:

git push origin master 

...what is the meaning of origin in this context?

like image 627
Ickhyun Kwon Avatar asked Mar 11 '11 08:03

Ickhyun Kwon


People also ask

What does Origin mean in git?

In Git, "origin" is a shorthand name for the remote repository that a project was originally cloned from. More precisely, it is used instead of that original repository's URL - and thereby makes referencing much easier. Note that origin is by no means a "magical" name, but just a standard convention.

What does git push origin master -- force do?

The --force option for git push allows you to override this rule: the commit history on the remote will be forcefully overwritten with your own local history. This is a rather dangerous process, because it's very easy to overwrite (and thereby lose) commits from your colleagues.


2 Answers

git has a concept of "remotes" - these are like easy nicknames for a repository, so you don't have to use its full URL every time you want to refer to another repository.

origin is just a remote like any other, but you see it very frequently since when you clone a repository for the first time, git clone will by default set up a remote called origin to refer to the URL that you cloned from.

If you do git remote -v that will show you all the remotes you have set up in your local repository, and the URLs that they refer to. (You'll see that it's a bit more complex than I said above, in that a remote can refer to a different URL for pushing and fetching, but you probably don't need to worry about that. :))

like image 145
Mark Longair Avatar answered Oct 11 '22 06:10

Mark Longair


origin is the default name of the remote git repository you cloned from. Have a look at .git/refs/remotes/origin/* and .git/config within your sources to see how git knows about it.

like image 40
skuro Avatar answered Oct 11 '22 04:10

skuro