Git Logo 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

Our Audience

Developers who are...

  • ...new to source control
  • ...new to Git
  • ...know a little about Git, but want to know more

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
Git Branch Symbol Image courtesy of GitHub via WikiMedia Commons via the MIT license

Getting Started

Where Do I Get Git?

Microsoft Windows Logo Windows Download the installer from http://git-scm.com/download/win
Mac OS X Logo 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 Logo Mac OS X <10.9 Download the installer from http://git-scm.com/download/mac
Linux Penguin Logo Linux Install using your distribution's package manager

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
						

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

Two Dogs Play-Fighting 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

Branching


git checkout -b mybranch
						

Questions and Discussion