Hi All, and Git gurus in particular
VS Code is great, The WPI extensions are awesome, the example programs are great.
Getting a new example into GitHub is not so much fun…
This is the process I have found to work after a couple of hours of playing around. I plan to give this to my students, but I am posting here in the hope that there will be suggestions for improvement.
I would welcome comments from any Git gurus about a better sequence.
-
Create a new repo on GitHub (my example is GettingStarted). Importantly, do NOT initialize with README, license etc.
-
In VS Code, use the WPI extension “Create Project” to create a new project (I used the GettingStarted example). Make sure you have ticked the “Create new folder” option
-
In VS Code, go to the Source Control pane. It will say “No source control providers registered”. Initialize a new local repo by clicking the little button at top left of the pane (hover over it and it will say “Initialize repository”). It will ask you to pick a workspace folder - I have been using the same folder as the project.
-
It will then ask if you want to open the new repo or add to workspace. I have been adding to workspace.
-
The source control pane will now show all the files that have been added. Hover over the heading “CHANGES” and you will see a “+” appear, to stage the new files. Click the “+”.
-
Now at the top of the pane, click the tick mark to commit the staged changes to the local repo.
-
We are half done - we have a local and a remote repo, but they are not connected. Open a terminal window (see the “Terminal” command in the VS Code menu bar)
-
In the terminal window, enter the following git commands:
git remote add origin https://github.com/<repo owner>/<repo name>.git
git push -u origin master
<repo owner> and <repo name> are replaced with the correct values from the repo you created in step 1. You can actually copy the URL from the button in GitHub that says “Clone or download”. For example, mine looked like:
git remote add origin https://github.com/CDM-Robotics/GettingStarted.git
- Now go to your repo on GitHub and refresh the page - you should now see your project files.
Now to update from your local to GitHub.
Make a small change to one of the files. Make sure to save the file.
Go to the Source Control pane. If the CHANGES area is not showing anything, go back and make sure you modified and saved a file.
Click the “+” button to stage the change, then the top tick mark to commit to the local repo. You might want to put a message in the message box first (“First modify” or something more profound)
Now click the ellipses near the tick mark, and select “Push to…”, then select the GitHub remote.
Now go back to GitHub and check the modification has made it through.
As noted above, any comments on improving this process would be very welcome.
Regards
David Evans
6072 - TritonTech