Creating a Remote Repository and Connecting with git remote add0%

Creating a Remote Repository and Connecting with git remote add

Beginner12 min read•Updated: Jul 11, 2026
Study MaterialsCheatsheet

Creating a Remote Repository and Connecting with git remote add

Connecting your local repository to a remote repository on GitHub bridges your local computer with the global cloud. The git remote command manages these connections.


1. Creating a Remote Repository on GitHub

  1. 1
    Log into your GitHub account.
  2. 2
    In the upper-right corner, click the + icon and select New repository.
  3. 3
    Fill in the repository details:
  • Repository name: e.g., ecommerce-dashboard.
  • Description: Short explanation of the project.
  • Visibility: Choose Public (visible to the world) or Private (restricted to you and invited collaborators).
  • Initialize this repository with:
  • > [!IMPORTANT]
  • If you are pushing an existing local repository, uncheck "Add a README file", .gitignore, and license! Creating these on GitHub will create an initial commit on GitHub, causing diverged history that blocks your first push.
  1. 1
    Click Create repository.

2. Understanding Git Remotes: The origin Convention

A remote in Git is simply an alias (a bookmark shortcut) pointing to the URL of a repository hosted on the internet or a local network.

By universal convention in the Git ecosystem, the primary default remote repository is named origin.

Output
Local Repository Remote Repository on GitHub
[ D:/projects/app ] <=========== origin ============> [ https://github.com/sumit/app.git ]

3. Connecting Local Repo to Remote (git remote add)

GitHub displays quick-setup terminal instructions. To link your existing local repository to the remote URL:

Bash / Terminal
git remote add origin git@github.com:sumit-msk/ecommerce-dashboard.git

Using HTTPS URL:

Bash / Terminal
git remote add origin https://github.com/sumit-msk/ecommerce-dashboard.git

4. Managing and Inspecting Remotes

A. List Configured Remotes

Bash / Terminal
git remote
# Output: origin

B. List Remotes with Fetch and Push URLs (-v verbose)

Bash / Terminal
git remote -v

Output:

Output
origin git@github.com:sumit-msk/ecommerce-dashboard.git (fetch)
origin git@github.com:sumit-msk/ecommerce-dashboard.git (push)

C. Change a Remote URL (set-url)

If you switch from HTTPS to SSH or if the repository was renamed:

Bash / Terminal
git remote set-url origin git@github.com:sumit-msk/new-repo-name.git

D. Remove an Outdated Remote (remove)

Bash / Terminal
git remote remove origin

Interactive Quiz

Practice Quiz

Question 1
What is a Git remote?
Question 2
What is the conventional default name given to the primary remote repository in Git?
Question 3
What command links a local repository to a remote GitHub repository URL under the alias origin?
Question 4
Which command displays all configured remotes along with their target fetch and push URLs?
Question 5
If you already have a local project with commits, why should you uncheck "Add a README" when creating a new GitHub repo?
Next Lesson

Pushing and Pulling Code: git push -u origin main and git pull

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

PrevNext