Welcome to USDC's Git workshop repository! This workshop aims to teach the following:
- Learning outcome #1
- Learning outcome #2
- Learning outcome #3
Prerequisites for this workshop:
Feel free to complete the activities in this repository at whatever own order and pace feels right for you. We have included instructions below for optional guidance.
Create a fork of the git-workshop repository (which can also be referred to as a "repo") using the Fork button on the upper right corner of this repo page.
In the owner dropdown, select your own GitHub username. You can keep the "Copy the main branch only" field checked.
This creates your own personal copy of the git-workshop repo on your GitHub account. Your changes on your forked repo will only be reflected in your personal GitHub account's version of the git-workshop code. Think of it as making your own copy of a Google doc. Your changes on your created copy will not change the original Google doc you copied.
The goal here is to familiarize ourselves with the commit and push mechanisms. When you are finished making edits to a file, the next step is to "commit" your changes. You can think of a commit as a photo snapshot of this project at a specific point in time. You can always refer to previous "commits" in your project's git timeline if you need to refer back to specific changes.
You can create as many commits as you'd like, but if you want to publish these commits to GitHub you the next step is to "push" your changes. You can think of pushing a change as having a Google doc stored locally on your computer. After you've made some changes and you want to share these with your team, you'd upload the Google doc to Google Drive where its hosted online for others to view.
Open the analysis_standards.md file.
At the top right of the page you'll see a pencil icon, click it.
Instead of viewing the file you'll have options to either "edit" or "preview" the file.
Check that the "edit" tab is selected. Based on the sample data provided in the file, write down some recommendations on how you might perform data extraction, cleanup, validation, analysis, or presentation.
After you've finished making your changes, click the "Commit changes..." button at the top right of the page. This will open up a modal with options for providing a commit message, an extended description, and buttons to either "Commit directly to the main
branch" or "Create a new branch for this commit and start a pull request".
In the commit message input, provide a short but descriptive message about your change. The extended description is optional. Ensure "Commit directly to the main
branch" is selected then click the "Commit changes" button.
In the previous exercise we practiced committing new changes and pushing them directly to the main
branch. For many projects it is common to treat the main
branch as the production version which is used by live users. As a result, it is best practice to not commit changes directly to the main
branch as to not accidentaly introduce breaking changes.
To solve this problem, we can create our own branches and work on our changes there. This allows us to add new changes in an isolated environment which does not impact live users or other team members.
To create a new branch on GitHub, we'll need to go back to the main page. If you're working from your forked repository, clicking the "Code" tab at the top of the page will take you here.
After doing so, you'll want to find and click the "1 branch" button.
Next, you'll want to click the "New branch" button at the top right. This will open a modal with options for adding a "New branch name" and specifying the source of a branch.
Set the branch name to anything you'd like. For the source branch:
- The first dropdown specifies which repository, keep this as the default which is set to your forked repository.
- The second dropdown specifies the source branch, or in other words the branch you're making a copy of. Keep this as the default which is set to the
main
branch.
Click the "Create new branch" button.
Under "Your branches", you should now see the new branch.
Hover over and click the branch you created, in our example above this was branch-1
but click the branch with the name you chose. After doing so, this will redirect you to the home page of your GitHub repository.
Once you're at the home page of your GitHub repository, the key difference to take note of is dropdown button for "Switching branches/tags". You'll notice your newly created branch is selected instead of main
. You now have a carbon copy of the main
branch where you can make your own isolated changes.
Open the script.md file. Before we making any changes, take note of the URL at the top of your browser.
The URL path should be similar to the following: https://github.com//git-workshop/blob//script.md.
Notice how <your-new-branch-name is prepended before script.md. This indicates you're viewing the the version of script.md stored on .
Try changing to main and notice how the branch you're on changes. Open a new tab and set the URL in your browser to the following (be sure to change to your GitHub username): https://github.com//git-workshop/blob/main/script.md
Before we continue, check that you're working in the branch we created in the previous exercise. The URL at the top of your browser should say: https://github.com//git-workshop/tree/
Open the script.md file. Like we did in a previous file, click the pencil icon at the top right of the page to edit the file.
You can either make your own custom changes to the file or copy/paste our sample code snippet below into script.md:
def print_name(name):
print(f`Your name is ${name}`)
Now, let's take what we practiced before in the previous exercises. After you've made your changes, click the "Commit changes" button at the top right of the page.
Add a short but descriptive commit message in the modal that pops up, then ensure Commit directly to the <your-branch-name> branch
is selected. Then click "Commit changes".