Skip to content

Instantly share code, notes, and snippets.

@johnsogg
Last active December 5, 2023 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnsogg/56df0f970bd9e019da861fd37ceb42f8 to your computer and use it in GitHub Desktop.
Save johnsogg/56df0f970bd9e019da861fd37ceb42f8 to your computer and use it in GitHub Desktop.
Git and GitHub Crash Course

Git and GitHub Crash Course

This crash course is meant for my CS 2270 students at CU-Boulder. It might be helpful for others, but there might be course-specific content in here. The internet has goo-gobs of tutorials for git. Students: you should totally check those out! I'm making this as a sort of one-stop-shop for your 2270 needs.

If you've not familiar with command line interfaces, you might want to read the command line interface crash course to help you understand this.

Git is an open source source code management tool, and it is easily the most widely used tool in its category. GitHub is a company that provides git-related services, including repository hosting, user and team management, security, and collaboration interfaces. Git exists independently of GitHub. There are other systems like GitHub such as Gitlab, BitBucket. We happen to use GitHub in this course. GitHub is a good tool to know, but git is essential.

I'll start with the helpful "cheatsheet" stuff first, and then launch into a flowery exposition of various git-related concepts. If you want to know more about a line in the cheet sheet there might be a section below that expands on the ideas.

Cheat Sheet

(recall that $ represents the CLI prompt and # is a comment that extends to the end of line - see the CLI thing if you need help making sense of this)

$ git clone git@github.com:cu-cspb-2270-Fall-2023/pa8-johnsogg.git # clone a repository using SSH
$ git clone https://github.com/cu-cspb-2270-Fall-2023/pa8-johnsogg.git # clone a repo using HTTPS
$ git status # print a list of interesting files: new, modified, deleted, tracked or untracked
$ git add . # adds all new/updated files in this dir to a changeset
$ git add my_awesome_code.cpp # adds a single file to the changeset
$ git commit # commit all changeset files to a new local git revision - it prompts you for a message
$ git commit -m "I perfected my code!" # commit all changeset files to a new git revision with a message
$ git push # pushes local commits to the 'remote', which is GitHub in our case
$ git fetch # asks the remote for a list of branches
$ git checkout -b some-feature # create a new branch called some-feature and switch to it
$ git checkout some-feature # switch to a branch called some-feature that already exists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment