LIT Logo

Legal Innovation & Technology Lab
@ Suffolk Law School

GitHub, an Introduction (Hello World)

Estimated Time (Reading & Exercises): ~45 min.

You are welcome to join our Slack Team. There you can ask and answer questions relating to this lesson under the #howto channel. See How To for more.

Overview

GitHub is a tool for collaborating on coding projects. It’s like track changes for code, except it actually works. Here’s a quick rundown, with GitHub nomenclature italicized. Your project is stored in a code repository (repo). A repo is just a collection of files and folders. Individual contributors make a copy of a repository by cloning it. This process creates a copy of the repository on your personal computer in a location you choose. You can then edit this code as you like, editing individual files or adding new ones. GitHub will keep track of your changes, and once you have things where you like them, you commit your changes. After you commit changes, you are ready to synchronize (sync) your local copy with the central repository. This process will incorporate your changes into the main repository and update your local copy with any changes made by fellow contributors. The magic here is that GitHub manages everyone’s changes, doing its best to work out conflicts. In practice, people can make changes to the same file and GitHub makes sure that they get merged properly. Technically, the process of synchronizing is a combination of pulling changes other people have made from the repo to your local copy and pushing your committed changes back to the repo.

When you're collaborating, however, it's nice to add a little discussion and review to the process. Customarily, a repo is comprised of multiple branches, slightly different versions of your code. Branches aren't created every time someone makes a change to the repo, rather they are parallel copies of code that have been intentionally split to give developers some breathing room. Though one may push and pull to a single master branch, it is customary to create multiple branches, allowing folks to work on code in their own development branch without changing the Master Branch. The Master Branch should contain only code that is ready to go live, what's called production code (i.e., the code that is being used in the real world/in production). One only merges branches with the Master Branch when it's ready to go live. How does this happen? Well instead of making a push to your development branch, you make a pull request, asking a Master Branch administrator to pull your changes into the Master Branch. So you make pulls and pushes to an ancillary/development branch until such time as you think it's worth adding to the Master. Then you make a pull request to have your work added to the Master Branch and an admin decides if it's added. You can learn more about this workflow by reading Understanding the GitHub Flow.

Sometimes, however, you don't have the permissions needed to push to a branch or to create a new branch within a repo. In these cases you can create your own version of the repo by forking the repo (as in a fork in the road). When you fork a repo, you make a clone of it which you control. You can keep this code and your changes to yourself, or you can make a pull request to have one of the original repo's admins incorporate your changes just as you can for changes to a branch within a repo.

Okay, let's give it a try. If you haven't already, you can create a GitHub account here (choose the free plan). You should also download and install the desktop app.

Exercises

If you're a Lab student, be sure that you use the GitHub account you provided to the Lab. We'll be looking at http://github.com/[your username]/hello-world to check your work.

Hello World

Complete GitHub's Hello World activity (~20 min).

Hello World Too

Now let's make an edit to your repo using GitHub Desktop. This is helpful because unlike the exercise above, most of your edits to a repo are not likely to be made in the browser while visiting GitHub.com. They're probably going to me made on your computer. Note: your layout may differ depending on your version of GitHub Desktop.

If you haven’t confirmed your email with GitHub, you won’t be able to login when using the desktop app. So be sure you clicked the verify email link in the email you received from GitHub when you signed up.

screen shot

Open your copy of the GitHub desktop application. Sign into GitHub from inside the app. To do this, click on File in the top left of the app., then Options....

screen shot

Choose the Accounts tab and click Sign in.

screen shot

Enter you credentials and sign in.

screen shot

Now we want to clone your repo. Click on File then Clone repository.

screen shot

Select the GitHub.com tab and search for hello-world. Choose a place to put your copy of the repo (local path), and click Clone.

screen shot

This should result in GitHub coping the repo to your computer. When it's done it will look something like this.

screen shot

Using your text editor, open up and edit the README.md file inside the local copy of your repo. Specifically, add "-too" to the end of "hello-world" in your heading, causing it to read "hello-world-too". Save your changes.

screen shot

GitHub will notice the change and make note of it like so. What your seeing is a breakdown of the changes. If you're happy with the changes, you can commit to them. Do this by giving your changes a title and a description (e.g., "Added too to title"). Click Commit to master.

screen shot

Now that you're committed you changes you now need to push them. You can do this through the menus under Repository or on the top bar by clicking on Push or Sync.

screen shot

GitHub will move the files to the Master branch of the repo.

screen shot

Your changes should now be visible on GitHub.com at your repo's page. If you're a Lab student, this final push is like turning in your work for this exercise.

screen shot

Back to Main How To GitHub Pages →