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 Overflowbelow 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
Below will reinitialize your local repo; also clearing remote repos (ie origin):
git init
Then below, will create 'origin' if it doesn't exist:
git remote add origin [repo-url]
Else, you can use the set-url subcommand to edit an existing remote:
git remote set-url origin [repo-url]
Also, you can check existing remotes with
git remote -v
set-url origin and add origin
when the best scenario to use git remote add?
Videos
What does two commands exactly do. Can anyone explain me how does this two commands work and in what cases I should use them. I often get confuse that should I use set-url origin command after adding the origin. Help me to clear my thoughts...
hello, i have a question about git. what is git remote add use for? when the best scenario to use this feature?