Working with Github Remote

I’m a novice when it comes to Github but I’d like to use Visual Studio Workbench with it. I’ve been trying all day to figure out how to push, commit or otherwise put my code on Github from my local Visual Studio Workbench setup. I’ve searched everywhere and I can’t seem to grasp it to put the pieces together. When I see something promising, the menus in Visual Studio are all different and I don’t have those options. Is there a guide somewhere to show how to managing source control within our development platform? Maybe a good article relating to Particle on how to set this up with the remote Github?

Any help is appreciated. Thanks!

2 Likes

So I think the best first step would be to create a new repository on GitHub that you will connect to your project in Workbench.

https://github.com/new

Enter a Repository Name and leave Initialize this repository with a README unchecked.

Click Create Repository.

You will then see this screen.

From the …or push an existing repository from the command line section, copy the entire line beginning with git remote add origin to your clipboard. You will need this later.

Next, open your project folder in Visual Studio Code.

Open the Terminal by clicking the Problem menu on the bottom left, under the settings gear, and then click on TERMINAL. A terminal should open.

In the terminal enter the following commands:

git init
# This will create a git repository out of your project folder.
git remote add origin https://github.com/...
# This is the line that you copied from GitHub

Your project folder is now a git repository and connected to GitHub. You should see the pending changes in the Source Control tab.

To upload the current state of your project to GitHub you can enter a commit message, click the plus to stage all changes, and then click the check to commit.

Next, you will need to push the commit to GitHub.

Click the push button on the bottom left to open the push menu. VSCode will ask for your GitHub credentials and then push your commit to the repository on GitHub.

An easy way to confirm that the push worked is to refresh the repository page on GitHub. You should see your files and information about your commit.

That’s the basics of getting a workbench project up on GitHub. Let me know if you have any questions.


I’m not much of an article writer, but I probably should start doing it more often.

8 Likes

@nrobinson2000, Thanks for the instructions. I think I had done some of it, definitely had the Github repo there and the “git init” said it was done. I also had the clone command there and set up. When I go to commit, that works. Then the push doesn’t. It shows me an error git . I’ve tried pulling but it still won’t work. Any additonal ideas?
Thanks again!

Does the git log contain any useful information?

OK, I think I got it. I have at least uploaded 1 file successfully. I deleted my repository on Github and then deleted my local .git folder. After that, I followed your instructions and this seemed to work. It was kind of a convoluted way of fixing it, though.

But, you really helped lead me in the right direction @nrobinson2000. Thank you!

3 Likes