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.
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.
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
After An Upload (to Github)git clone email@example.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://firstname.lastname@example.org/msg39091.htmlLinus on "clean history."