4

I have a local project on VS code and a private Repository with the same name on Github. Now, when I follow these steps

Step 1

Step 2

Step 3

It says, Github repository alreadt exists as shown in the last image. Please guide me, how to publish to that existing Github Repository. I know a hack as:

  1. Clone that private Repo to my PC.
  2. Copy my new code to that Repo and Sync to set all things up.

But I want to know a proper short way.

Thanks!

DevLoverUmar
  • 11,809
  • 11
  • 68
  • 98

2 Answers2

3

Go to 3 dot menu inside the git tab of VS Code

enter image description hereenter image description here

Once you click on Add Remote, you can now add your repository url or github link and give any remote name like origin alpha beta or anything you wish to and get going ... enter image description here

In the similar way you can now remove your old github remote by selecting remove remote and then selecting your other remote which you want to remove

Hrithik Tiwari
  • 121
  • 1
  • 6
2

After you committed, try to push directly. If you don't have a remote setted yet, Visual Studio Code should tell you to which repository you want to push into.

  • Thanks for your answer but It ask to pull first. No success yet – DevLoverUmar Aug 27 '20 at 06:23
  • 1
    This is because your remote repository is not empty. If you are sure that your local code is okay, then you should force the push. To do that, check this link https://stackoverflow.com/questions/42635701/is-it-possible-to-git-push-force-in-vscode. – Alessandro Artoni Aug 27 '20 at 06:29