Introduction to Version Control with Git – Why use source control? – Getting Started



Introduction to Version Control with Git – Why use source control? – Getting Started

0 0


git-101

WorkShop: Intro to Version Control with Git

On Github TownHack / git-101

Introduction to Version Control with Git

Presented by Zackary Lowery and David Myers at Town Hack Columbus 2014

This presentation is available online at https://townhack.github.io/git-101

Have all related sites up before presenting.

Introduce myself and how I use Git professionally. Tie Git use into the Hackathon over the weekend.

Mention reveal.js and how it works (press space to move forward through presentation). Maybe bring up the Github page?

Also, ask the following questions:

Have you ever...

  • ...shared code on a Flash driver?
  • ...accidentally closed a file before you could hit undo?
  • used Dropbox for projects?
  • ...emailed yourself a file?
  • ...needed to prove that a fellow classmate did no work during a group project?

Our Audience

Developers who are...

  • ...new to source control
  • ...new to Git
  • ...know a little about Git, but want to know more
Make verbal note that anyone is welcome to listen in, of course.

Why use source control?

  • Allows developers to work in teams effectively
  • Tracks file history over time
  • Allows for diverging branches of code
  • Allows for different changesets or branches to be merged

Why Use Git?

  • Encourages frequent commits
  • Branching is a first class operation
  • Provides an entire local copy of the repository
  • Access to a large community of open source projects
  • Access to services such as Github and Bitbucket
Image courtesy of GitHub via WikiMedia Commons via the MIT license

Getting Started

Where Do I Get Git?

Windows Download the installer from http://git-scm.com/download/win Mac OS X >=10.9 Attempting to run git from the terminal for the first time will prompt you to install the XCode Command Line Tools Mac OS X <10.9 Download the installer from http://git-scm.com/download/mac Linux Install using your distribution's package manager Mention that David (and if a large turnout, myself) can help with downloading and installing Git.

Let's clone a repository!

git clone https://github.com/TownHack/git-101.git

Make a Change...

index.html, Line 52

<p>
	<small>
		Presented by {{Your Name Here}}
		at
		<a href="https://townhack.co">
			Town Hack Columbus
		</a>
		2014
	</small>
</p>

...Wait, That's Not Right - Revert That!

git checkout index.html
This would be a good time to mention tab-completion and mention the diversity of the checkout command.

Starting From Scratch

mkdir myproject
cd myproject
git init

Add Your Changes

touch README.md
git add README.md

Where Were We?

git status

Commit Locally

git commit -m "Add a README file to myproject"

Set Remote

git remote add origin https://github.com/<user>/<repo>.git

Pull

git pull

Push Remotely

git push

When Conflict Occurs

Photo courtesy of Aris Sánchez via the Attribution-NonCommercial-ShareAlike 2.0 Generic license

Definition

conflict be incompatible or at variance; clash.

What Does a Conflict Look Like?

The number of planets are
<<<<<<< HEAD
nine
=======
eight
>>>>>>> branch-name
.
Example borrowed from Github Mention that solving a conflict is just like adding, committing, and pushing any other change.

Branching

git checkout -b mybranch

Questions and Discussion