Problem #1

Code only on one computer

Problem #2

Can't get deleted code back

Old Solutions

 

  • USB Drive
  • ZIP and Email
  • Dropbox/OneDrive/Google Drive

Git: A Version Control System

Added index.html

Changed  index.html

Added style.css

Benefits

 

  • Track and record file changes
  • Compare and analyze code
  • Restore old code
  • Merge code from other computers
  • Merge code from team members

Installing Git

 

Configuring Git


git config --global user.name "Chris Sevilleja"
git config --global user.email "chris@scotch.io"

Configuring Git


git config --global user.name "Chris Sevilleja"
git config --global user.email "chris@scotch.io"

Repository

 

Storage container for our project

Starting a Repo

git init

Git Process

Working Files

Staging Area

Final Commit

Repo Status

git status

Commit

 

A recorded change to the repository

Staging Area

 

Prepare updated files for commit

Add to Staging

# add all
git add <filename>

# add all
git add -A

Viewing Commits

git log

GitHub

Remote Repository

 

A hosted repo not on your current machine.

Remote Repo Benefits

 

  • Available anywhere
  • Work with team members
  • Code safety (distributed)

Some Choices

 

GitHub

Fun Features

 

  • Contribute to open source projects
  • Try to create a commit streak
  • See all commits
  • See who to blame
  • Analyze a project

SSH Keys

 

Recommended way of authenticating connections.

How They Work

Your Computer

Private Key

Server

Public Key

Creating an SSH Key

ssh-keygen -t rsa -C "chris@scotch.io"

Branches

Master Branch

New Feature Branch

Merge

Viewing Branches

git branch

Creating Branches

git branch my-branch

Switching Branches

git checkout my-branch

Deleting Branches

git branch -d my-branch

Merging Branches

git merge my-branch

Merge Conflict

 

When git can't automatically merge two branches.

 

Easy to fix.

Getting Started with Git

By Chris Sevilleja

Getting Started with Git

  • 431
Loading comments...

More from Chris Sevilleja