Introduction to Git & GitHub

dsa dsa dsa dsd a dsadadaddadsadsadsadsa dsa dsa dsd a dsadadaddadsadsadsadsa dsa

Kostas Bariotis

  • Full stack engineer
  • ATEI graduate
  • https://kostasbariotis.com

Workshop Agenda

  • What is version control
  • How Git works
  • What is GitHub
  • Git basics
  • Some exercises

What is version control

 

  • Also Version Control Systems or Source Code Management

  • Manage changes to source code over time

  • Distributed version control

  • Users keep entire code and history on their location machines
  • Users can make any changes without internet access (Except pushing and pulling changes from a remote server)

What is Git

  • Started in 2005
  • Created by Linus Torvald to aid in Linux kernel development
  • Git isn’t the only version control system (subversion, mercurial, bazaar, etc)

How Git Works

It's complicated!

How Git Works

Key Concepts: Snapshots

  • The way git keeps track of your code history

  • Essentially records what all your files look like at a given point in time

  • You decide when to take a snapshot, and of what files

  • Have the ability to go back to visit any snapshot

  • Your snapshots from later on will stay around, too 

How Git Works

Key Concepts: Commit

  • The act of creating a snapshot

  • Can be a noun or verb

  • “I commited code”

  • “I just made a new commit”

  • Essentially, a project is made up of a bunch of commits

  • Commits contain three pieces of information: 1. Information about how the files changed from previously 2. A reference to the commit that came before it

  • Called the “parent commit” 3. A hash code name

  • Will look something like: f2d2ec5069fc6776c80b3ad6b7cbde3cade4e

How Git Works

Key Concepts: Repositories

  • Often shortened to ‘repo’

  • A collection of all the files and the history of those files

  • Consists of all your commits

  • Place where all your hard work is stored 

  • Can live on a local machine or on a remote server (GitHub!)

  • The act of copying a repository from a remote server is called cloning

  • Cloning from a remote server allows teams to work together

  • The process of downloading commits that don’t exist on your machine from a remote repository is called pulling changes

  • The process of adding your local changes to the remote repository is called pushing changes

How Git Works

Key Concepts: Branches

  • All commits in git live on some branch

  • But there can be many, many branches

  • The main branch in a project is called the master branch 

What is GitHub

  • https://github.com
  • Largest web-based git repository hosting service
  • Aka, hosts ‘remote repositories’
  • Allows for code collaboration with anyone online
  • Adds extra functionality on top of git
  • UI, documentation, bug tracking, feature requests, pull requests, and more!

So what does a normal repository looks like?

Git Basics

  • Create a new local Git repository
  • Commit changes
  • Create a branch
  • Merge a branch
  • Revert changes
  • Create a new GitHub repository
  • Send a Pull Request

Git Excercises

  • Additional Resources
  • Official git site and tutorial: https://git-scm.com/
  • GitHub guides: https://guides.github.com/
  • Command cheatsheet: https://training.github.com/kit/ downloads/github-git-cheat-sheet.pdf
  • Interactive git tutorial: https://try.github.io/levels/1/challenges/1
  • Visual/interactive cheatsheet: http://ndpsoftware.com/git-cheatsheet.html

Additional Resources

deck

By Kostas Bariotis