Saturday, November 5, 2022

Git: Adding Remote Origin to a Local Git Repo

When working with a new Git repo (ADO git, github.com, etc.), I typically perform a git clone in order and start development in the clone of the remote repo. While on a flight, I found that the Internet was timing out when I performed git clone from the remote repo. The remote repo contained only a Readme.md file but git clone was still timing out.

It was a long flight and I wanted to be able to add/commit files to a repo so I created a folder for the project and created a local git repo using git init:

mkdir projectAbc
cd project Abc
git init

Atlassian provides an excellent explanation of the git init command on git init (to quote):


Once I had stable Internet I want to associate the local Git repo with the project's remote repo hosted in Azure DevOps. To create this association, invoke the git remote add origin <repo URL> command from the root folder of the local Git repo. 

If SSH is used to access the remote repo, then git remote add origin should be invoked as follows where boldface is the URL used to access the remote Git repo:

git remote add origin softwarepronto@vs-ssh.visualstudio.com:v3/softwarepronto/ProjectAbc/ProjectAbc

If HTTPS is used to access the remote repo, then git remote add origin should be invoked as follows where boldface is the URL used to access the remote Git repo:

git remote add origin https://softwarepronto.visualstudio.com/DefaultCollection/ProjectAbc/_git/ProjectAbc


The git remote add command is documented by Github.com at Managing remote repositories (to quote):




No comments :

Post a Comment