How to add new origin in git

In this article let’s discuss about How to add new origin in git. Let’s go through the following methods without any delay.

Method 1:

below is used to a add a new remote:

git remote add origin git@github.com:User/UserRepo.git
below is used to change the url of an existing remote repository:

git remote set-url origin git@github.com:User/UserRepo.git
below will push your code to the master branch of the remote repository defined with origin and -u let you point your current local branch to the remote master branch:

git push -u origin master

If you are facing any issues with the above approach then try the alternative that is given below. It may look similar by have a try!

Method 2 :

git remote add origin 

Hope the above solution works.

Realted Posts : Git overwrite local branch with remote