Git Lab

Git... What is?

Git is NOT:

  1. A tool that keeps track of a file's history
  2. A tool that tells you who screwed up the code
  3. A tool that lets you share code with other people
  4. A site that you can go to download rails homework

 

Git

  • Git is a distributed version control system
  • It lets you work on different versions of the code, and to easily manage those versions

Github

A social website powered by Git that hosts the code

Local

Github (Origin)

Local

Origin 

Initial Commit

origin/master

Local

Origin

Initial Commit

Initial Commit

origin/master

local/master

git add

  • Telling what you want Git to Commit

git commit

  • A version of your code that you want to save

git log

  • A log of the history of your commits

git checkout "branchname"

  • change your current branch

git branch "branchname"

  • Branch off your code into a new direction

Quick Git Commands

Branches

  • When you want to create a "branch" in the git tree
  • It's a copy of the code
  • Master is the holy and sacred branch
  • When updating master, you want to merge a branch into the master branch

Pull Requests

  • A branch that you "request" to be merged into master
  • This is a github feature

Local

Origin

Initial Commit

Initial Commit

master

master

update-readme

Change

Title

Local

Origin

Initial Commit

Initial Commit

master

master

update-readme

Change

Title

add-rails

Init Rails Repo

git pull origin master

  • Take the code that's at origin Master and merge it into your current branch

git push -u origin HEAD

  • Take your current branch, and push to the branch that corresponds to it on Github.
    • Create the branch if it doesn't exist 

git status

  • A ton of useful information that you'll always need

Quick Git Commands

Local

Origin

Initial Commit

Initial Commit

master

master

update-readme

Change

Title

add-rails

Init Rails Repo

Init Rails Repo

add-rails

Local

Origin

Initial Commit

Initial Commit

master

master

update-readme

Change

Title

add-rails

Init Rails Repo

Init Rails Repo

Local

Origin

Initial Commit

Initial Commit

master

master

update-readme

Change

Title

Init Rails Repo

Local

Origin

Initial Commit

Initial Commit

master

master

update-readme

Change

Title

Init Rails Repo

Init Rails Repo

Local

Origin

Initial Commit

Initial Commit

master

master

update-readme

Change

Title

Init Rails Repo

Init Rails Repo

update-readme

Change

Title

Change Title Ending

readme-update

Local

Origin

Initial Commit

Initial Commit

master

master

update-readme

Change

Title

Init Rails Repo

Init Rails Repo

update-readme

Change

Title

Change Title Ending

Local

Origin

Initial Commit

Initial Commit

master

master

update-readme

Change

Title

Init Rails Repo

Init Rails Repo

update-readme

Change

Title

Change Title Ending

Change Title Ending

Local

Origin

Initial Commit

Initial Commit

master

master

update-readme

Change

Title

Init Rails Repo

Init Rails Repo

update-readme

Change

Title

Change Title Ending

Change Title Ending

Fix merge conflicts

Local

Origin

Initial Commit

Initial Commit

master

master

update-readme

Change

Title

Init Rails Repo

Init Rails Repo

update-readme

Change

Title

Change Title Ending

Change Title Ending

Fix merge conflicts

Fix merge conflicts

Local

Origin

Initial Commit

Initial Commit

master

master

update-readme

Change

Title

Init Rails Repo

Init Rails Repo

Change Title Ending

Change Title Ending

Fix merge conflicts

Change

Title

Fix merge conflicts

Local

Origin

Initial Commit

Initial Commit

master

master

Init Rails Repo

Init Rails Repo

Change

Title

Change Title Ending

Change Title Ending

Fix merge conflicts

Change

Title

Fix merge conflicts

Quick Tips

  • Commit Often
  • Pull Often
  • NEVER push to master unless everyone agrees it is the right decision
  • Share code through branches! Never send .zip files.
    • You can pull just a branch from Github too!
  • Practice makes perfect

Lab Time:

github.com/rails-decal/lab8