WDD 130: Web Fundamentals

W01 Prepare: Publishing Your Pages to GitHub

Overview

In previous activities you have completed the following:

In this activity you will learn to push or upload your changes to GitHub. Because GitHub is hosting your website for others to view, this step of pushing is the way you will publish your pages to the Web.

Prepare

In order to send changes from the files on your computer to GitHub, you need to go through several steps. Some of these steps may seem overly complex, but you should remember that Git is a very powerful tool used by professional software developers every day, it is capable of doing even more that what you will see in this course. In future courses you will use even more features, so it is useful to get familiar with the core features now.

When you created a repository at GitHub and cloned it to your computer, it make a complete copy of that repository on your computer. In order to send your changes to GitHub, you must first commit them into the repository on your computer and then you can push those changes to GitHub.

The following diagram shows the stages on your computer that a file must pass through in order to arrive at GitHub.

The stages of Git: Working directory, Staging, Local Repo, GitHub.
The stages of pushing changes to GitHub.

In this class, you will only need to commit your saved changes to your local repository and sync them with GitHub.

Workflow

The following steps outline the general process of your workflow in this class.

Edit files and folders

The first stage of the publishing process using Git is to edit files and folders in the working directory of your repository. You do not need to do anything special for this. You simply need to open your wdd130 folder in VS Code, browse to the files and folders you want to work on and make your changes including additions, deletions, and modifications. Git is automatically keeping track of those changes for you.

Use Source Control to Manage Uploads

Select the Source Control icon in VS Code's Activity Bar.

By default, the Activity Bar is found on the left-hand side of the screen. If the Activity Bar is not visible, click View -> Appearance -> Activity Bar to turn it to visible.
Source Control Icon in VS Code
Source Control Icon in VS Code's Activity Bar

On the Source Control tab in VS Code, you will see a list of all the changes you have made. If you would like, you may click on a file and see the changes. VS Code can show the old and new versions to you and highlight the differences.

Shows the changes made to a file.
Screenshot showing the changes made to one of the files.

Committing Changes to your Local Repository

The stages of Git: Working directory, Staging, Local Repo, GitHub.
The stages of pushing changes to GitHub.

Whenever you commit changes to a repository you must provide a commit message. This is an important message that describes the changes you are making that can be viewed in the future. It is useful if you or anyone else wants to know the purpose of these changes. If you do not enter a commit message, Git will not allow you to commit these changes into your repository.

The easiest way to add a commit message is to type it into the Message box directly above the Commit button.

Shows the commit message and the commit button.
Screenshot showing commit message box and the commit button.

After typing a commit message, you can click the Commit button to commit your changes into your local repository.

At this point, your changes will not show up in the list of changes, because they have been added to the repository. However, they are NOT yet at GitHub. In order for your changes to get to GitHub, you must push them.

If you forget to add a commit message and click the Commit button, VS Code will open a new file and give you a chance to add your message to that file.

Shows a file open for a missing commit message.
Screenshot showing the file that VS Code opened because of a missing commit message.

Type your message at the top of this file and save it and close it to allow Git to finish the commit process.

Pushing changes to GitHub

The stages of Git: Working directory, Staging, Local Repo, GitHub.
The stages of pushing changes to GitHub.

Once you have committed your changes to your local repository you are ready to push them to GitHub.

When you have changes in your local repository that are not present at GitHub, the Sync Changes button will appear. You can click this button to push your changes to GitHub.

Shows the sync changes button.
Screenshot showing sync changes button.

When you click this button, VS Code may tell you that you are about to push and pull changes from origin (your GitHub repository) on the main branch. Click the button to allow it to perform this action.

Shows the push / pull dialog box.
Screenshot showing dialog box asking if it is ok to push and pull.

If you are working with other people or you have made changes from another computer, this button will first try to pull or download any changes from GitHub that you do not have on your computer, then it will push your changes to GitHub.

Verifying your changes at GitHub

Once you have Pushed your changes to GitHub, you can navigate to your GitHub repository in a browser and see them.

The URL for your GitHub repository is: https://github.com/your-username/wdd130 (replace your-username with your actual username). At your repository, you should see your commit message along with how long it has been since you made the change:

Shows the changes at GitHub.
Screenshot showing a commit message at GitHub.

If you would like, you may click on the commit message to see the changes that were made.

It may take a minute for your changes to get deployed to your GitHub pages site.
When they are finished you can see the updated page in a browser by visiting your page URL, which is: https://your-username.github.io/wdd130 (replace your-username with your actual username).

Activity Instructions

This activity will help you make a change and commit and push that change to GitHub.

  1. Make a change to one of the html files in Week 01. (You may do something as simple as adding a blank line).
  2. Save your changes.
  3. Click the source control icon in the activity bar of VS Code.
  4. Enter a commit message and commit your changes to the local repository.
  5. Sync your changes to push them to GitHub.
  6. Verify that you can see your commit message at GitHub.

Submission

You have now completed all of the learning activities for this week.
Return to Canvas to submit the W01 Learning Activities quiz.