CodeBlanks Logo Icon CodeBlanks

git remote

Learn to add a remote repository with git remote.

What Is a Remote Repository?

A remote is a copy of your local Git repository hosted online or on another server. You use git remote add to connect your local project to a repository on GitHub.

git remote add origin https://github.com/ayse/ilk-projem.git

This command gives the remote repository the name origin. origin is the conventional default remote name in Git projects.

View the Remote Repository Connection

You can run git remote to list the remote repositories you have added. Use the -v option to see more details, including repository addresses.

git remote -v

The output shows the fetch and push addresses for each remote. This lets you verify that the connection is configured correctly.

Practice Create the First Remote Connection

Connect the local project to its GitHub repository. Add https://github.com/ayse/ilk-projem.git using the name origin. Then list the remote connections with their details.

Starter code

terminal
# Uzak depoyu ekle

# Bağlantıları ayrıntılı listele

Sample solution

terminal
git remote add origin https://github.com/ayse/ilk-projem.git
git remote -v

Expected output

origin https://github.com/ayse/ilk-projem.git (fetch)
origin https://github.com/ayse/ilk-projem.git (push)

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which command adds a remote repository named origin?

  • git add remote origin URL
  • git remote origin add URL
  • git push add origin URL
  • git remote add origin URL Correct answer

Explanation: <code>git remote add</code> adds a remote repository. <code>origin</code> specifies its name, and the URL specifies its address.

2 Add a Remote Repository

Question
git remote ____ origin https://github.com/ayse/ilk-projem.git
Answer
git remote add origin https://github.com/ayse/ilk-projem.git

Explanation: <code>add</code> creates a new remote repository connection. <code>remove</code> deletes a connection, while <code>rename</code> changes its name.

3 Remote Commands

Term Meaning
git remote Lists remote names
git remote -v Shows detailed addresses
origin Default remote name
git remote add Adds a new remote

All lessons in Beginner