Sunny0101
Sunny0101

Reputation: 476

Trying to link my VS Code with a DIFFERENT GitHub repository

A friend of mine had set up my visual studio code with my GitHub account which works great. I now want to move onto a new repository on GitHub but still have it linked with my VS Code but my issue is that when I do a test push with the new project, it's still pushing my changes to the repository on Git where I don't want it to go? Please can someone help me with this. Note, I do NOT have Git installed, I just use the U.I from GitHub. I want my VS Code to be linked with https://github.com/KaysHaydock/Kay-Hangman-Game.git and not the repo that I don't want to touch: https://github.com/KaysHaydock/SOFT355-HangMan.git

I now fear I may have messed up the link between my VSCode & KaysHaydock/SOFT355-HangMan.git - Is there any commands I can use to check which project is linked with what github?

Terminal:

Kayleighs-MacBook-Pro:SOFT355-HangMan-ATTEMPT-LIVE Kayleigh$ git remote add origin https://github.com/KaysHaydock/Kay-Hangman-Game.git
fatal: remote origin already exists.
Kayleighs-MacBook-Pro:SOFT355-HangMan-ATTEMPT-LIVE Kayleigh$ git push -u origin master
Counting objects: 2, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 276 bytes | 276.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/KaysHaydock/SOFT355-HangMan.git
   cec379f..6d9e280  master -> master
Branch master set up to track remote branch master from origin.

Upvotes: 1

Views: 2862

Answers (1)

GoodDeeds
GoodDeeds

Reputation: 8497

The output shows that the origin remote currently points to the old GitHub repository. You can either update the URL of the remote of create a new remote.

Changing the URL of the origin remote:

Use:

$ git remote set-url origin <path-to-new-repository>

Then, to push

$ git push origin master

Creating a new remote:

To create a new remote, named say newremote, use:

$ git remote add newremote <path-to-new-repository>

Then, to push:

$ git push newremote master

Upvotes: 2

Related Questions