D - Git in VSCode
Make sure that you've completed A to C before continuing.
By the end of this class you will have:
Learned how to use the Git ("Source Control") menu items inside VSCode
Made changes, staged, and committed our file(s)
Connected VSCode to our GitHub accounts for profile / setting synchronization
Published our folder to GitHub for safe-keeping online
Cloned an existing repository
Made changes to the code
Pushed those changes to the remote repository
Source Control (Git) in VSCode
In the previous lesson we created a local repository for our Gr. 11 Review Task.
The left-hand menu in VSCode has a section for "Source Control". The icon is a Git branch. When you have an active repository, this section will provide the same Git controles we have in the console.
To test it - make a change in your code file (add a comment, for example). The icon should show a notification. When you click on it, you'll be able to stage your changes (+ button), add a message, and commit to the local repo.
Publishing to GitHub
When all changes in a local repo are committed, the "Commit" button changes to "Publish Branch". By clicking this, you are asking VSCode to create a new remote repository.
You will be asked to allow this and will be asked to authorize VSCode to communicate with GitHub on your behalf.
Once complete, your local repository is sent to GitHub and you now have both a local and a remote.
Note: You do not need to synchronize all local commits with the remote repo. You can just do it periodically to ensure your changes are safe.
Git Fetch & Sync
Sometimes you will change your code in the remote repo. Maybe you add a README file, make some simple adjustments, or work on the code on a different computer and push the changes to GitHub.
To check for changes, we run the Fetch command. All of the Git commands can be found in the kabob menu inside the Source Control window.
Fetch checks for changes online.
Sync or Pull will attempt to synchronize the remote changes into your local repo. However, if you made conflicting changes in both locations you will need to fix any problems that arise.