Getting Into Git
Upcoming SlideShare
Loading in...5
×
 

Getting Into Git

on

  • 294 views

This was a presentation I gave at the 2012 NorthEast PHP conference, in Cambridge, MA.

This was a presentation I gave at the 2012 NorthEast PHP conference, in Cambridge, MA.

Statistics

Views

Total Views
294
Slideshare-icon Views on SlideShare
294
Embed Views
0

Actions

Likes
0
Downloads
1
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Getting Into Git Getting Into Git Presentation Transcript

    • Getting Into Git8/11/2012Rick Umalirickumali@gmail.com@rickumalihttp://tech.rickumali.com/This presentation is on Google Drive at:http://sn.im/git-talk-2012There you can read the speaker notes for thispresentation. You can also provide feedback at:https://joind.in/6830
    • Questions I Plan to AnswerWhat is source control?What is the big deal with Git?Can you show me a little Git?Commits. Branches. Merges. Remote repos.
    • What is Source Control?Source code control is the most importantpractice a coding professional can do.A mechanism to track changes in source code.Used for version history, auditing, andrecovery.
    • Revision Control Example: Wiki
    • Revision Control Example: GitThis is what well be trying.
    • GitGit is an open source, distributed versioncontrol system designed for speed andefficiency.● Freedom● No "server" required● Unique architecture
    • Installing Githttp://git-scm.com/book/en/Getting-Started-Installing-GitThe installation is very easy!
    • Warning: Command Line Ahead
    • Our Example: A Basic Drupal Module
    • Creating a "Repository"Lets pretend were developing a Drupalmodule.% cd web/sites/all/modules% mkdir dumpstamp% cd dumpstamp% git init"git init" creates the entire Git repository. Noserver interaction required!
    • Committing Your First FileTo commit means to save the state of yourwork. You must first add this change to thestaging area.% vi README.txt% git add README.txt% git commit -m "First commit. README file."Use git help to learn all the switches. -mstands for message.
    • Looking at the Repository History% git logEach commit contains an ID, along with theauthor information from earlier, and a timestamp.% gitkGUI tools can help you visualize the repo.
    • Adding More Files% vi dumpstamp.info dumpstamp.module% git status% git add .% git commitThis second commit saves the work of addingtwo files by using git add ..The .module and .info files are the tworequired files for every Drupal module.
    • Enabling Our Drupal Module% drush pm-info dumpstamp% drush pm-enable dumpstamp
    • Examining Changes to Files% vi dumpstamp.module% git status% git diff% git add dumpstamp.module% git commit% git logThe above is a typical workflow.Git offers suggestions and hints as you use it.
    • Doing More Changes% vi dumpstamp.module% git diff% git commit -aOr even:% git commit -a -m "Commit message."Another typical workflow.
    • Looking at the Log AgainThe history can be examined different ways.% git log% git log --format=short% git log --format=oneline% git log --oneline
    • Revisiting HistoryYou can revisit any point of your history.% git checkout SHAIDEvery commit is known by its SHA ID.This is the first step in making a branch! (Usegit checkout master to revert.)
    • Branching and Merging Next, But...What we have covered so far is probably 70-80% of what you will do with git.Adding and committing files are the heart ofgit (and any version control system).
    • Git encourages experimentation, by makingbranching very easy.Branching
    • Branching: git branch% git branch BRANCH SHA1% git checkout BRANCHMake some edits on a change below themaster, then commit.git branch makes a branch from the branchyoure on (default branch is master).
    • Branching: Starting StateSHA 1AmasterNOTE: master is a branch thats created by default.
    • Branching: Make Some ChangesSHA 1ASHA 2Bmastergit commit
    • Branching: Making a BranchSHA 1ASHA 2Bmasterbranch1git branch "branch1" SHA1Agit checkout "branch1"OR git checkout -b branch1 SHA1A
    • Branching: Changes on the BranchSHA 1ASHA 2Bmaster branch1SHA 3C(Make changes in "branch1".)git commit
    • Visualizing the Branches
    • MergingBringing two branches together.First checkout the branch you want to mergeinto (typically master), then merge thebranch.% git checkout master% git merge BRANCH
    • Merging: Starting StateSHA 1ASHA 2Bmaster branch1SHA 3C
    • Merging: Two StepsSHA 1ASHA 2Bmasterbranch1SHA 3CSHA 4Dgit checkout mastergit merge branch1
    • Merging: The Hard PartManual merging may be required.
    • Visualizing the Merge
    • Whew!
    • Remote BranchesYou can browse public Git repositories forcode that you want to examine or use.You can upload a local Git repository to apublic Git repository.
    • Common Public Git Repositories
    • Browsing and Grabbing Codegit clone git@github.com:rickumali/RickUmaliVanityWebsite.git
    • Uploading Code (to Github)Create a key pair on your machine.Create a repository (on Github).Add a remote (via git remote add).Upload your code (via git push).
    • Creating a Key Pair
    • Creating a Repository
    • Adding a Remote, then Upload
    • After An Upload (to Github)git clone git@github.com:rickumali/DumpStamp.git
    • Next StepsInstall Git.Commit your code changes frequently.Log verbosely (in commit messages).Experiment (branch) often.
    • Getting Into GitRick Umalirickumali@gmail.com@rickumalihttp://tech.rickumali.com/Thank you!
    • Resourceshttp://git-scm.org/Both "Pro Git" book, and Git referencehttp://gitref.org/A "quicker" Git referencehttp://www-cs-students.stanford.edu/~blynn/gitmagic/"Friendlier" Git walk-through (git magic).http://drupal.org/node/803746A workflow for using Git with Drupal.http://www.mail-archive.com/dri-devel@lists.sourceforge.net/msg39091.htmlLinus on "clean history."
    • Resourceshttp://www.youtube.com/watch?v=4XpnKHJAok8Linus Torvalds (Git creator) (May 07)http://www.youtube.com/watch?v=8dhZ9BXQgc4Randal Schwartz (Perl expert and Git old-timer) (Oct07)http://www.youtube.com/watch?v=ZDR433b0HJYScott Chacon (Pro Git author) (July 11)