git - remote add origin vs remote set-url origin

0 votes

I created a new repo:

git init
echo "# MESSAGE" >> README.md
git add README.md
git commit -m "first commit"

What I want here is, I want to push the commit to the empty repo. So I have to set a remote. I want to know what the difference is between these two commands:

git remote add origin git@github.com:User/UserRepo.git
git remote set-url origin git@github.com:User/UserRepo.git

I also what to know, what happens if I execute git remote set-url origin just after git init? What is the use of using the above commands if there is already an origin?

May 13, 2022 in Git & GitHub by Kichu
• 19,050 points
1,561 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Git & GitHub

0 votes
1 answer
+5 votes
4 answers

Git push vs git push origin

In simple words git push command updates ...READ MORE

answered Apr 23, 2019 in Git & GitHub by Hiran
249,318 views
0 votes
1 answer

How to add a remote git repository in Jenkins

Follow these steps: Step 1 Go to Manage ...READ MORE

answered May 23, 2019 in Git & GitHub by Alok
13,538 views
0 votes
1 answer

How to remove remote origin from Git repo?

Hi@akhtar, You can remove or add a new ...READ MORE

answered Sep 4, 2020 in Git & GitHub by MD
• 95,460 points
6,977 views
0 votes
1 answer

How to change the URL for a remote Git repository?

Hi@akhtar, You can use the git remote command ...READ MORE

answered Nov 21, 2020 in Git & GitHub by MD
• 95,460 points
1,053 views
–1 vote
1 answer

Having problem in Github and remote Git repo with production and development code

I think you could start with this. The ...READ MORE

answered Apr 10, 2018 in Git & GitHub by shubham
• 7,340 points

edited Dec 15, 2023 by Khan Sarfaraz 1,026 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,942 views
+2 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP