Week 1. GitHub And Getting to Know Your Computer
Learning Objectives
- Discuss the advantages of a static website.
- Create a GitHub account.
- Create a GitHub repository.
- Learn the basic commands and functionality of Git and GitHub.
- Link your GitHub remote repository to your local machine via GitHub Desktop.
GitHub Basics
This module will walk you through setting up your GitHub account, and will introduce you to some common tasks that can be completed through the GitHub interface. It has been adapted from Learn Static’s Introduction to GitHub and Evan Will’s go-go gh-pages.
Before we get started, let’s clarify some terms:
Git is a popular free, distributed version control system–i.e. a piece of software used to track the history of changes in a folder of files. Git can be used on your personal computer, or by online services to track the development of a project, such as…
GitHub, a popular web platform for hosting Git repositories–i.e. a place to store and sync your project files online. Think of it as Google Drive for code with super robust “track changes” baked in. Built around the powerful version control of Git, it provides a handy web interface for managing, editing, and collaborating on repositories.
Some GitHub Key Terms
Infrastructure:
- Repository: A collection of folders and files.
- Branch: A parallel version of a repository. Allows for editing and experimentation without effecting the main branch or your project site.
- Main: The default branch that will store the source code that generates your site.
- readme: A file to provide information to the visitors of the repository such as who made it, what it does, and other basic information.
Actions:
- Clone: Copy your project to your very own computer.
- Fork: Copy another user’s repository to your account.
- Commit: A Snapshot of your repository. The git equivalent of saving.
Getting Started with GitHub
The steps below will familiarize you with the GitHub platform, and with how it tracks the changes you make to your files.
Step 1. Create a GitHub account
- Open https://github.com in a new tab
- Click the “Sign up” button
- Enter your email and create a username and password to complete the sign up process
Step 2. Create a GitHub Repository
Follow these steps to copy code from another repository into your own and start editing it:
- Make sure you’re logged into your account on GitHub
- On GitHub, click the “+” plus icon in the upper right of the nav bar.
- Select “New repository”
- This brings you to a “Create a new repository” form. Follow these steps:
- In the Repository name text box, give your repository the name
dsf-github-basics. If you’d like to create your own name for the repository, be sure to use a lowercase name without spaces or odd characters. Dashes (-) or underscores (_) are okay. - In the Description text box, add
A place to learn GitHub basics. - Select the option for “Public” repository.
- Leave the “Include all branches” option Unchecked!
- Click on the green button “Create repository from template”. This will take you to your new repository.
- In the Repository name text box, give your repository the name
Step 3. Explore the interface and repository
- Explore your repository:
- gray bar: most recent activity; commit history
- repo list: files and folders, looks like directory
- readme preview
- about: click and describe this repository
- Explore navigation bar:
- code: brings us back to main repo page
- issues/pull requests/etc.: more advanced
- settings: modify repo, initiate github pages
Step 4. Edit README file
-
Click on the
README.mdlink. This will open your README file.The README file is a place to describe your repository. By default, GitHub displays the README on the repository home page, so it is often the first place visitors will look for information about your project.
-
In the top right corner of the README file, locate and click on the pencil icon.
You are now in GitHub’s editing mode.
- Delete this line of text and instead type
# My Project. - Add text below your title to describe your project. For example, you can add
A place to learn GitHub basics
Step 5. Make a Commit
When you make a commit, Git takes a snapshot of the changes you made and permanently stores it in your repository’s history. Your “commit message” is a short description of what the changes do or why you made them–this is a required note to your future self and your collaborators to help everyone understand the code and history.
- To commit the changes you just made to your README file, scroll to the bottom of the page where you made your README edits. You’ll see a box titled “Commit changes.”
- In the text box directly underneath “Commit changes,” type
update project title, or a brief message of your choosing that indicates what changes you made to this file. - Skip the option to add an extended description to the commit, and keep the box checked next to “Commit directly to the main branch”. (Note that you can add an extended description of your changes if you need to, but usually a brief commit message will work just fine).
- Click on the green “Commit changes” button. This will save your changes and take you back to your repository’s home page.
- Scroll down to the bottom of your repository to view the new title you added to the README file.
You can view recent commits on your repository’s home page. Commit messages and their timestamps are located to the right of the repository files.
Step 6. View the Changes
Let’s take a closer look at the changes you’ve made to the README file:
- On your repository’s home page, scroll back up and locate the README.md file link. To the right of the link, you should see the commit message you just created (it should say
update project title). -
Click on this commit message (not on the filename).
When you click the commit message, GitHub will show you the changes made and the files edited during that commit. Deletions will display in red while additions to a file will display in green.
- Click your repository’s name (located in the top left of the window) to return to the repository’s home page.
Remote to Local
While GitHub’s interface allows for editing, developing, and launching a website, working locally will help you work effectively and efficiently. This section will introduce you to the concept of remote and local repositories through the use of GitHub Desktop.
Step 1. Install GitHub Desktop
- Navigate to GitHub Desktop and download the appropriate version of GitHub Desktop for your operating system.
- Follow the prompts to complete the installation. For more information, see Installing GitHub Desktop.
- Sign in to your Github.com account via the GitHub Desktop prompt.
- Select
authorizeafter reviewing access prompt. - When viewing
configure gitprompt, selectuse my GitHub account name and email address. - Click
finish
- Arrive at
Let's get started.prompt.
Step 2. Clone Your Repository Using GitHub Desktop
- Using your browser, go to your GitHub dashboard or repository list and find the repository we created in the previous module. If you followed along, it will be titled
dsf-github-basics. - On your repository landing page, find the green button titled
< > Codeand click to open a drop down menu. - Under the
localtab, selectOpen with GitHub Desktop. - GitHub Desktop will open and show your respository url and a suggested local path. If these look accurate and/or are acceptable, click
clone.
Step 3. Explore GitHub Desktop and its Functionality
- Explore navigation bar:
- Current repository dropdown menu
- Current branch dropdown menu
- Suggested action:
- Fetch
- Pull
- Push
- Explore commit viewer:
- Changes
- History
- Commit message
- Explore main viewer:
- Open the repository in your external editor
- View the files of your repository in Finder/Windows Explorer
- Open the repository page on GitHub in your browser
Homework
- Please try to download and install VS Code (if you do not have a different preferred text editor) before our next session. If you have trouble, we can walk through the process during our session.
- Begin collection five to ten objects for your prototype website. We will discuss further next session, but if you have you can read through the Object Guidelines (just the section the page jumps to) and metadata information from CollectionBuilder. If these guidelines are confusing or you’re not sure what they’re asking for, don’t worry, we will also walk through it together.