below is used to add a new remote:

git remote add "origin" [email protected]:User/UserRepo.git

below is used to change the url of an existing remote repository:

git remote set-url "origin" [email protected]: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 main

Documentation

Answer from Shubham Khatri on Stack Overflow
🌐
GitHub
docs.github.com › en › get-started › git-basics › managing-remote-repositories
Managing remote repositories - GitHub Docs
Learn to work with your local repositories on your computer and remote repositories hosted on GitHub. ... To add a new remote, use the git remote add command on the terminal, in the directory your repository is stored at.
🌐
CraftQuest
craftquest.io › homepage › git version control › 2. git fundamentals › adding a git remote repository
Adding a Git Remote Repository - Git Version Control | CraftQuest
August 29, 2022 - To add a remote, we need to grab the remote URL first. Depend­ing on how you have your remote repos­i­to­ry set up, you can do this either via http or ssh or even as a direct file.
🌐
Git
git-scm.com › book › ms › v2 › Git-Basics-Working-with-Remotes
Git - Working with Remotes
$ cd grit $ git remote -v bakkdoor https://github.com/bakkdoor/grit (fetch) bakkdoor https://github.com/bakkdoor/grit (push) cho45 https://github.com/cho45/grit (fetch) cho45 https://github.com/cho45/grit (push) defunkt https://github.com/defunkt/grit (fetch) defunkt https://github.com/defunkt/grit ...
🌐
Assembla
articles.assembla.com › all collections › using git › getting started › how to add a new remote to your git repo
How to Add a New Remote to your Git Repo | Assembla Help Center
#set a new remote git remote add my_awesome_new_remote_repo git@git.assembla.com:portfolio/space.space_name.git #Verify new remote git remote -v > my_awesome_new_remote_repo git@git.assembla.com:portfolio/space.space_name.git (fetch) > my_awesome_new_remote_repo git@git.assembla.com:portfolio/space.space_name.git (push)
🌐
Atlassian
atlassian.com › git › tutorials › syncing
How to Add Remote Git? | Atlassian Git Tutorial
December 16, 2025 - The git remote add command will create a new connection record to a remote repository. After adding a remote, you’ll be able to use <name> as a convenient shortcut for <url> in other Git commands.
Find elsewhere
🌐
Medium
medium.com › swlh › how-to-add-a-second-remote-to-a-local-repository-7d0e36f18d58
How to Add a Second Remote to a Local Repository | by John Rumingan | The Startup | Medium
September 24, 2020 - git remote add <shortcut-name-of-second-repository> <url> Confirm that you’ve done this correctly by again using git remote -v. I’m giving it the shorthand name second. You should see this: origin git@github.com:<repository> (fetch) origin ...
🌐
W3Schools
w3schools.com › git › git_set_remote.asp
Git Set Remote from GitHub
{{title}} Get Started Git What is SSH? {{title}} Add SSH {{title}} Set Remote {{title}} Edit Code Pull from {{title}} Push to {{title}} {{title}} Branch Pull Branch from {{title}} Push Branch to {{title}} GitHub Flow {{title}} Pages Git GUI Clients · {{title}} Fork Git Clone from {{title}} {{title}} Send Pull Request ·
🌐
Git
git-scm.com › docs › git-remote
Git - git-remote Documentation
With --add, instead of replacing the list of currently tracked branches, adds to that list. ... Retrieves the URLs for a remote. Configurations for insteadOf and pushInsteadOf are expanded here.
🌐
GeeksforGeeks
geeksforgeeks.org › git › how-to-add-remote-origin-in-git
How to add remote origin in git? - GeeksforGeeks
July 23, 2025 - Step 5: Use below command to add the remote origin: ... Here, <HTTPS_URL> will be the earlier mentioned your repo URL you copied from that site. ... This command will show the remote URLs associated with your repository. Step 1: Proceed to your remote repository in the hosting platform like GitHub, GitLab, or Bitbucket.
🌐
GitKraken
gitkraken.com › home › learn › git remote
Git Remote | Learn Git
April 23, 2025 - We’ll use GitHub as our example below: Then, open GitKraken, access the folder in the upper left, and under the Clone tab, paste the repo URL. Alternatively, for an even easier Git clone, select the integration of choice from the Clone tab: Once cloned and opened, the GitKraken Git GUI will automatically populate the REMOTE pane on the left, with the name of the remote and a clear list of all of your remote Git branches.
🌐
GitHub
github.com › git-guides › git-remote
Git Guides - git remote · GitHub
To make it easier to pull any changes to update the local copy of the fork from the original repository, many people add the original repository as a remote also. It's typical to name this remote upstream. There are four commands within Git that prompt communication with the remote.
🌐
Graphite
graphite.com › guides › add-remote-git-repo
How to add a new remote to your Git repo
Git manages this reference by storing the remote’s URL and configuration in a local .git folder. So, if you have a local repository and also have a project hosted on GitHub, you can create a remote in your local repo that points to the GitHub repo URL.
🌐
CloudBees
cloudbees.com › blog › git-remote-add
Follow These Steps To Add a New Remote To Your Git Repo
Bitbucket provides a remote URL that looks like the following link: https://username@bitbucket.org/username/your-repo.git. ... New repository. On the Create new repository page, enter a repository name of your choice. Leave all other options unchanged and click on the green Create repository button at the bottom of the page. An empty GitHub repo will be set up.
🌐
GeeksforGeeks
geeksforgeeks.org › git › how-to-use-git-remote-add-origin-command
How to Use 'git remote add origin' Command? - GeeksforGeeks
July 23, 2025 - git remote add origin https://github.com/username/repository · Step 3: Verify the Remote URL · git remote -v · This command lists all configured remote repositories and their URLs, verifying that the remote has been added correctly.
🌐
GitHub
docs.github.com › en › migrations › importing-source-code › using-the-command-line-to-import-source-code › adding-locally-hosted-code-to-github
Adding locally hosted code to GitHub - GitHub Docs
When prompted, select Push an existing local repository to GitHub and enter the desired name for your repository. If you want your project to belong to an organization instead of your user account, specify the organization name and project name with ORGANIZATION-NAME/PROJECT-NAME. Follow the interactive prompts. To add the remote and push the repository, confirm yes when asked to add the remote and push the commits to the current branch.
🌐
Git Tower
git-tower.com › learn › git faq › how to add a remote in git
How to add a remote in Git | Learn Version Control with Git
5 days ago - $ git remote -v origin https://gittower@github.com/gittower/example.git (fetch) origin https://gittower@github.com/gittower/example.git (push) Voila, looks good! In case you are using the Tower Git client, you can add a remote repo easily through ...
🌐
TheServerSide
theserverside.com › video › How-to-use-the-git-remote-add-origin-command-to-push-remotely
How to use the git remote add origin command | TheServerSide
This tutorial explains how to use the git remote add origin command to connect a local project or repository to a service like GitHub, GitLab or Bitbucket.