GIT REMOTE SET-URL ORIGIN

Josh Raiborde
3 min readSep 11, 2021

This blog is sort of a continuation of my last blog, ActionView — Template — Error.

Here’s a little recap from that blog:

A couple of days ago, I was contacted by a recruiter about a position for web developer. This lead to the first round of an interview for the job position on the phone. We went over the usual questions like, where’d you go to school, what did you learn, what projects have you done, etc. The interview lasted about 15–20mins.

Towards the end of the interview, the recruiter asked me what projects I’m proud of. I mentioned Noodles-Oodles. Noodles-Oodles is a fun Ruby-on-Rails blog post web-app for lovers of noodles who can sign-up and create posts and reviews for noodles. It uses the Ruby on Rails framework to include reasonable validations for the simple attributes and standard user authentication which also allows logins such as Facebook, Twitter, Foursquare, GitHub. The use of nested resources with RESTful URLs are employed to view predictable URLs. ActiveRecord Query methods are used, rather than native ruby methods to perform queries on the database.

How that blog connects to this blog is through Noodles-Oodles.

I had forgotten that I had not only moved the location of my projects on my local machine but also had changed my username.

I was made aware of the latter issue when I was committing the changes to Noodles-Oodles.

After making changes to Noodles-Oodles, I typed in the usual commands in the terminal:

1. git add . app/assets/stylesheets/noodles.scss

a. the command adds file that was changed to be pushed to GitHub.

b. The file path of the file that was changed is needed

2. git commit -m “description of the commit”

a. this command gives a brief description of the change that was made.

3. git push

a. this command sends it to GitHub

now when I pressed Enter on my keyboard to push the changes to GitHub, I got a message in the terminal stating the following:

remote: This repository moved. Please use the new location:

remote: git@github.com:joshraiborde/Noodles-Oodles.git

To github.com:joshsrai/Noodles-Oodles.git

So, how do you fix this issue??

I googled it and found out the steps to resolve this issue on GitHub Docs.

The name of the topic is MANAGING REMOTE REPOSITORIES.

And the subtopic is CHANGING A REMOTE REPOSITORY’S URL.

Here are the condensed steps that I used.

There is HTTPS and SSH.

Here’s a link to a github md called GitHub Protocol Comparison by grawity.

It shows the differences between HTTPS and SSH and other protocols.

The same steps applies to both SSH URL and the HTTP URL.

1. Verify the remote’s URLs

a. In the project’s terminal type in:

git remote -v

# this will display the existing remotes

> origin https://github.com:joshsrai/Noodles-Oodles.git (fetch)

> origin https://github.com:joshsrai/Noodles-Oodles.git (push)

2. Set the url of the username that you want.

a. In the project’s terminal type in:

git remote set-url origin git@github.com:joshraiborde/Noodles-Oodles.git

3. Repeat step 1 to verify the new URL and you’re done!

a. In the project’s terminal type in:

git remote -v

> origin https://github.com:joshraiborde/Noodles-Oodles.git (fetch)

> origin https://github.com:joshraiborde/Noodles-Oodles.git (push)

Some things to note:

1. Before pressing enter to change the URL, verify the spelling because GitHub does not check to make sure this reference is correct through these steps.

a. If there is a typo, you will not get any kind of alert.

2. Any pushes to the URL with the OLD USERNAME, and also any web links that contain the OLD USERNAME, GitHub will still redirect to your NEW USERNAME, you’ll just keep getting this warning.

3. Best practice suggests to update your remote tracking URLs and weblink with your NEW USERNAME.

4. Because your OLD GITHUB USERNAME will be available for anyone to use and they happen to create a new repository with the same name, then the redirect for that repository will no longer work.

5. I did the added step of creating a dummy account of my OLD USERNAME.

I hope this has been clear and concise on how to change a remote repository.

--

--

Josh Raiborde

Hello, I am a young enthusiastic Software Engineer. Looking forward to an opportunity to use my skills for mutual benefits and growth as well.