1 of 13

Git and GitHub

2 of 13

Intro

This is a really difficult concept and it is common for beginners to struggle.

It’s normal, dont feel bad, you arent dumb.

You will probably end this class more confused than you are now, that’s ok, it’s the first step in learning git.

There are links to much more extensive courses on the last slide, it’s definitely worth investing the time to do one of them/

3 of 13

What is a terminal?

You can think of the terminal as the most basic interface for a program, the program without the user interface.

Why do we still use it in 2022?

  1. It is far easier to maintain as it does not require a frontend
  2. It works much the same on any platform (some difference between windows and everything else)
  3. Most of the users of programs that run in a terminal are devs and it is assumed devs have some baseline understanding of how to use a terminal

What if I’ve never used a terminal before?

You’ll get used to it, it is not super difficult, it’s just all new. You can learn some basics on youtube (here or pick a different one here one more tip, choose a tutorial that uses the operating system that you use, it is a little different on windows, mac or linux and it is very frustrating when it isn’t quite the same)

You can also just google how to do each thing until you remember off the top of your head.

4 of 13

What is Git?�

5 of 13

What is Github?

Git is the technology, GitHub is the cloud service

(like photos and google photos)

(or porn and pornhub)��Why are we using GitHub if GitLab is far superior?

Because most companies use GitHub and in your first job, they will probably use GitHub

6 of 13

James’s Setup

I’ve using a Mac, this is what I’ve already set up:

You can adjust your terminal profile with some useful configurations,� 1. Make VS code our default terminal editor (Instructions)

2. Add branch name to our terminal (instructions for Mac/Linux or Windows)

What I’ll show you how to do:

  1. Set up github SSH (instructions)
  2. Create a project
  3. Clone a repo/project
  4. Make a branch
  5. Make a merge request

What You will do:

  1. Clone a repo
  2. Make a branch
  3. Push your branch to the project
  4. Make a merge request

7 of 13

Start our App

  1. Create a new application using CRA (https://reactjs.org/docs/create-a-new-react-app.html)
  2. Create a new repo in GitHub (https://github.com/new)
  3. Connect your local app to the new GitHub Repo
  4. Create an initial commit
  5. Push it to the new GitHub repo

8 of 13

Some useful commands and what they do

9 of 13

Adding a feature

  1. Git pull latest changes
  2. Create feature branch https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging
  3. Make some changes, each ‘set’ of changes should be 1 commit (think of these as save points in a video game)
  4. Push your branch to ‘origin’ (github)
  5. Create a Pull Request
  6. Gain approval from code owners
  7. Merge with Main

10 of 13

Break!

11 of 13

Your Task

  1. Clone the Repo I created onto your local machine
  2. Create a feature branch
  3. Add your name to the list of COOL_NAMES
  4. Commit your changes
  5. Push your branch
  6. Create a PR
  7. Request Approval
  8. I will Merge once approved by 2 people

12 of 13

Second Task / Homework

  • Make your own react app using CRA
  • Copy James’s design if you want, or put whatever you want in there
  • Make a git repo for your project
  • Push your project to the repo
  • Create a feature branch
  • Change the text in your app
  • Push your changes and create a PR
  • Merge your PR

13 of 13

Further reading (all free)

Open Classrooms course (20 hours) https://openclassrooms.com/en/courses/5671626-manage-your-code-project-with-git-github

Git and GitHub - CS50 (Harvard Computer Science course) https://www.youtube.com/watch?v=eulnSXkhE7I

Git and GitHub for Beginners - Crash Course (free code camp) https://www.youtube.com/watch?v=RGOj5yH7evk