Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@stevegrunwell
Created July 14, 2012 14:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevegrunwell/3111724 to your computer and use it in GitHub Desktop.
Save stevegrunwell/3111724 to your computer and use it in GitHub Desktop.
Using Git for Version Control - WordCamp Columbus 2012

Using Git for Version Control

July 14, 2012

Instructor: Brian Layman (@BrianLayman)

Slides: http://www.slideshare.net/brianlayman/how-to-gitwiththeprogrambrianlaymanwordcampcolumbus2012

What is Version Control Software (VCS)?

Allows you to track and undo changes to you code while making it easier for multiple developers to work on the same code. Through branching, you can also work on several different versions of your code at once.

Popular systems

  • Git (FTW!)
  • CVS (Concurrent Versions System)
  • SVN (SubVersioN)
  • Mercurial

CVS and SVN are not predecessors to Git; they work in different ways (centralized version control v. distributed version control)

Advantages to distributed version control

  • Your own copy of the repo
  • Can commit to other servers
  • Fast, offline, redundant

SVN is simply not as advanced and "fakes" some of the standard VCS features

Basic version control terms

Repository - Your project and its history

Branch - A separate and unique version of your code

Tag - Your branch/repo at a specific point in time

Clone (Checkout in SVN) - Make your repo local

Add - Start tracking another file/tree

Commit (Git Only) - Add your changes to your local repo

Push (Commit in SVN) - Add your changes to a server

Pull (Update in SVN) - Bring in changes from a server

Revert (Git only) - Undo a local commit

Checkout (Revert in SVN) - Get a specific server revision

Snapshots - Local commits

Remote - Any other server with the current repository

Diff - Compare two file versions

Conflict - When a server has a different change to a line that is changed on your local computer

Merge - Bring the changes from one branch into your local branch (in SVN this is called PAIN)

Status - Shows the current state of the files

Log - All of the recent commits

Basic Workflow

  1. Create a repository
  2. Add a readme file to the repo
  3. Commit the change (with a proper commit message, naturally)
  4. Connect the repo to a remote server
  5. Push the change to the remote
  6. Make changes
  7. Commit (repeat)
  8. Pull updates to the server
  9. Push

GUI applications

Windows: SmartGit, TortoiseGit

Mac: Github for Mac, SourceTree

More: http://bit.ly/GitUIs

Of course, you can always be awesome and just use the CLI (or Git Bash on Windows)

Useful tips

git fetch - Shows what will come down with a pull

git reset HEAD README - Unstage changes to README

git checkout -- README - Revert file README

git revert - Commit changes to undo last commits

git commit --amend - Modify the last commit

git blame - Determine who made a specific change

Additional resources

Pro Git http://gitref.org/

See slides for more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment