Skip to content

Instantly share code, notes, and snippets.

@regnerjr
Last active June 24, 2016 17:05
Show Gist options
  • Save regnerjr/426ecf0fdeb0ee06c892734f283be4f0 to your computer and use it in GitHub Desktop.
Save regnerjr/426ecf0fdeb0ee06c892734f283be4f0 to your computer and use it in GitHub Desktop.
A guide for those new to git

The Car analogy

SVN is great in the way that a classic car (think 1960's Mustang) is great. Built to last. Simple to operate and fix. Pretty much reliable.

We are looking at a transition to git Git is like that new Chevy Camaro. Fuel Injected, computerized traction control, power steering, and much more. The good news is that any driver can get into either car and know how to drive. You don't really need to be scared away by the more powerful features. You just get in and start driving. As time goes on you might, choose to use some of the more powerful features, but for now lets just get working.

First steps

Before beginning work with SVN you will need to copy of the code on your machine. svn checkout http://some_amazing_url.com Similary for git you will need a copy from the server git clone http://some_amazing_url.com

See how similar this is. 😀

The nice thing about the git clone is that you have a full copy of everything the server has. Try looking at the history and see how fast it is. git log (you may be entered into the less or more pager, just hit q to end)

Branches

Just like SVN git has branches, but you will use them much more often. to make a branch just use the branch command. git branch my_amazing_feature_will_be_here use git branch to see all your branches. (notice the * that is the branch that you are currently viewing) (Remember these are your branches, local to your machine. Feel free to make and delete to your hearts content)

Want to view a different branch, Use the checkout command to switch to it git checkout my_amazing_feature_will_be_here

Where you might previously have had multiple folders for different versions of a project now you will work with multiple branches in git. All your code will live in one place, and use branches to handle multiple versions.

Protip

You can use git checkout to do more than just switch between your local branches. Use git checkout 4.6.3 to browse the code that was tagged for 4.6.3 release. Or use git checkout remotename/brancheName to view a remote branch, instead of trying to apply a patch from someone's code review. You can checkout the exact code that they have pushed to the server.

Workflow

Using Git is as easy as A B C.

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