Intro to GitHub

What is GitHub

Key concepts

Repository

  • The place where your code sits
  • Main folder that contains your project
  • Connection between the code on your computer and GitHub
  • Similar to a warehouse

 

Branch

  • A repository always has one master branch and can have multiple feature branches

Types of branches

 

  • Master branch
    • working version
    • the place where the final code sits
  • Feature branches
    • parallel versions of the code
    • playground to experiment new features

Master

Feature 2

Feature 1

Commit & Push

  • You made a change to the code and want to save it
  • You need to package it in a 'commit' and add a label (this is called commit message)
  • Once you packaged your changes, you'll need to 'push' them to the repository, and make them visible on GitHub

commit

commit message

Commits and Branches

  • Each commit happens on a branch
  • If you did something wrong, you can always go back to the previous commit
  • Think of it like adding lots of small boxes into a big one, that contains all the parts of your new feature

commits

Feature

Pull Request

  • When you're happy with the new feature you created and you want to add it to the Master branch (main code) you create a 'pull request'
  • In a collaborative environment other people review your code and suggest changes or improvements

Master Branch

Comments & improvements

Create PR

Commits

Create feature branch

Merge

  • Next step after a Pull Request is actually adding your features to Master branch 
  • Once you're sure your code is done, you can join changes from one branch to another one 
  • Think of this like putting your big box of features inside a warehouse, which is your project

The flow of events

Merge feature branch into master branch

Comments

&

Improvements

Create PR

Commits

Create feature branch

Master branch

Basic commands

Intro to GitHub

By Sonia Fernández Rodríguez

Intro to GitHub

  • 105