Git & GitHub Course
Git & GitHub
/
Beginner

git remote

Definition

A command that lets you create, view, and delete connections to other repositories (like those hosted on GitHub).

Explain Like I'm New

It's your address book. When you want to push your code to the cloud, Git needs to know the exact URL of the server. `git remote add` saves that URL into an address book and gives it a short nickname (usually 'origin').

Real World Example

You start a project locally. You go to GitHub and click 'Create Repository'. GitHub gives you a URL. You run `git remote add origin https://github.com/yourname/repo.git` so your local computer knows where to send the code.

Common Use Cases

  • •Connecting local projects to the cloud

Crucial Command Flags

Flag / OptionDescription
-vVerbose. Show the actual URLs for the remotes.
add [name] [url]Add a new remote repository.
remove [name]Remove a remote repository tracking.

Terminal Output

bash / terminal
# View your current remotes (and their URLs) $ git remote -v # Add a new remote named 'origin' $ git remote add origin https://github.com/user/project.git # Rename a remote from 'origin' to 'destination' $ git remote rename origin destination # Remove a remote connection completely $ git remote remove destination

Interview Questions

basic

  • What is the default nickname given to the primary remote repository?

intermediate

  • What command shows you the URLs of your current remotes?

Flash Cards

Question

Default nickname?

Click to reveal answer
Answer

`origin`.

Question

Show URLs?

Click to reveal answer
Answer

`git remote -v` (The -v stands for verbose).