Version Control with Git

Annika Backstrom
annika@sixohthree.com

@abackstrom

diff

--- a/ext/standard/strnatcmp.c
+++ b/ext/standard/strnatcmp.c
@@ -105,7 +105,8
 {
        unsigned char ca, cb;
        unsigned int ai, bi;
-       int fractional, result, leading = true;
+       int fractional, result;
+       short leading = 1;
 
        ai = bi = 0;
        while (1) {
@@ -120,7 +121,7 @@
                        cb = b[++bi];
                }
 
-               leading = false;
+               leading = 0;
 
                /* process run of digits */

patch

annika@fsck:~$ patch -p1 < changes.diff
patching file ext/standard/strnatcmp.c
Hunk #4 succeeded at 56 (offset -2 lines).

Git

A way to manage diffs.

What else?

Complexity

Complexity

Complexity

Making Commits

(master)$

(master)$ vi
(master)$ git add

(master)$ git commit

git log --graph --pretty=oneline --abbrev-commit

WTF PS1

(master)$ git add input

export PS1='$(__git_ps1 "(%s)")\$ '

Git vs. Subversion

echo "export EDITOR=vi" >> ~/.bashrc
svn diffgit diff
svn statusgit status
svn rm filegit rm file
svn add filegit add file

Git vs. Subversion

svn commit git commit -av
svn commit git add
git commit -v
svn up git pull
svn up git fetch origin
git rebase origin/master

In Practice

Workflow

Workflow

(master)$ git branch calllog-rest
(master)$ git checkout calllog-rest
(calllog-rest)$ vi index.php
...
(calllog-rest)$ git commit -av
(calllog-rest)$ git push origin HEAD

Code Reviews

Code Reviews

Great Commit Messages

Capitalized, short (50 chars or less) summary

Additional information, wrapped to 72 lines. Present tense. GitHub
will convert Markdown:

- List item
- With *bold*

Scenarios

Merging Branches

Merging Branches

Two branches (master and dev) each with a unique commit.

Merging Branches

(master)$ git merge dev

Merge made by recursive.
 index.php |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Merging Branches

(dev)$ git rebase master

(master)$ git merge dev

Updating ff6103a..bee41c4
Fast-forward
 index.php |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Merging Branches

(dev)$ git rebase master

(master)$ git merge --no-ff dev

Merging Branches

(dev)$ git rebase master

(master)$ git merge --squash dev

Resources