Git & GitHub
/Beginner
origin
Definition
The default conventional name that Git assigns to the remote repository that a project was cloned from.
Explain Like I'm New
'Origin' is not a magic keyword, it is literally just a nickname. Instead of typing `git push https://github.com/facebook/react.git main` 50 times a day, Git saves that URL in its address book under the nickname 'origin'. You type `git push origin main` instead.
Real World Example
When you clone a repository, Git automatically sets up the 'origin' remote for you behind the scenes.
Common Use Cases
- •Shorthand URL referencing
Terminal Output
bash / terminal
# Check where 'origin' actually points to
$ git remote -v
# Output:
# origin https://github.com/user/repo.git (fetch)
# origin https://github.com/user/repo.git (push)
# You can change the URL that 'origin' points to!
$ git remote set-url origin https://github.com/user/NEW-repo.git
Interview Questions
basic
- Do you HAVE to use the word 'origin'?
intermediate
- If you start a project with `git init` instead of `git clone`, does 'origin' exist?