Git and GitHub Workflow

  1. Overview
  2. Workflow
  3. Additional tutorials and references

Overview

Git is a popular version control system that software developers use to track changes to their source code over time. It also facilitates sharing code and collaboration through the GitHub website. In a nutshell, you use the Git program (either via the command line or with VSCode’s built in integration) to keep a history of changes, and then you share that history to GitHub. From GitHub, you can get the changes on another computer as can your partner(s).

VSCode has built-in support for using Git and GitHub. Using these tools the right way will make life easy when sharing changes across computers or partners.

Workflow

  1. When you sit down to code, start by pulling any changes from the server (GitHub) to make sure that you are working on the latest edition of the code.
    Show steps
    • Go to the Explorer Pane. At the bottom there is a Source Control section. Click blue Synchronize button, or open the VSCode Command Pallet and search for “Git Pull”.
    • Note that this action may overwrite any uncommitted changes you may have on your file system by stashing them.
    • At this point, you may have to resolve conflicts.
  2. Work on your source code and perform other changes to your project as normal.
  3. Commit your changes when you are satisfied with your code. You should commit when you reach a logical stopping point, e.g., you are finally satisfied with how your UI looks or when you finally fixed a bug.
    Show steps
    • Go to the Source Control section of the Explorer pane.
    • Type a short, informative descriptive message on what you accomplished/fixed in the textbox.
    • Click the blue Commit button. Note that your changes are not shared to the GiHhub repository.
    • Commit frequently and avoid giant commits.
    • A rule of thumb is that you should commit at least once each coding session.
  4. Share your work to GitHub by pushing. Click the “Synchronize” button in the Source Control section. You can push more than one commit at a time. VSCode may prompt you to save your files before synchronizing.

Additional tutorials and references

  1. A wonderful explanation of basic Git and it’s principles. Start here for a deeper understanding.
  2. VS Code using Git official beginner tutorial