Slide 1

Slide 1 text

Git Introduction For Subversion Users Ran Tavory Attributed to Totango

Slide 2

Slide 2 text

Who am I • A Developer, of course… • Migrated two teams from SVN to Git • Gormim

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Why git?

Slide 5

Slide 5 text

Why Git? • IT IS BETTER. There’s a site for that.

Slide 6

Slide 6 text

Git is a File System

Slide 7

Slide 7 text

All (most) Operations are Local and Fast! • Commit • Log (view history) • Diff • ...

Slide 8

Slide 8 text

Git is Distributed

Slide 9

Slide 9 text

Git is Fast

Slide 10

Slide 10 text

Lightweight (and local) Branching

Slide 11

Slide 11 text

Data Integrity

Slide 12

Slide 12 text

Staging Area

Slide 13

Slide 13 text

Stash Area

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Setup

Slide 16

Slide 16 text

Git Setup $ brew install git! $ git config --global user.name “Ran Tavory”! $ git config --global user.email “[email protected]” https://gist.github.com/rantav/ 5d6fb14057f062ecbc70

Slide 17

Slide 17 text

GitHub Setup https://help.github.com/articles/ set-up-git

Slide 18

Slide 18 text

Clone the Repo $git clone https://github.com/ rantav/devdev.git

Slide 19

Slide 19 text

The Basics

Slide 20

Slide 20 text

git status

Slide 21

Slide 21 text

git add

Slide 22

Slide 22 text

git diff

Slide 23

Slide 23 text

git diff More here: http://www.gitguys.com/topics/git-diff/

Slide 24

Slide 24 text

git commit

Slide 25

Slide 25 text

git commit --amend

Slide 26

Slide 26 text

git checkout

Slide 27

Slide 27 text

git rm

Slide 28

Slide 28 text

git mv

Slide 29

Slide 29 text

git log

Slide 30

Slide 30 text

git log -p

Slide 31

Slide 31 text

git log --word-diff

Slide 32

Slide 32 text

git log --stat

Slide 33

Slide 33 text

git log hacking

Slide 34

Slide 34 text

git remote

Slide 35

Slide 35 text

git pull

Slide 36

Slide 36 text

To rebase or not to rebase? • Prefer rebase • this keeps the commit log cleaner •git pl! • Sometimes an actual merge is needed • So don’t rebase • For example, when merging branches

Slide 37

Slide 37 text

git push

Slide 38

Slide 38 text

SVN Parallels

Slide 39

Slide 39 text

Git for SVN

Slide 40

Slide 40 text

Git for SVN

Slide 41

Slide 41 text

Git for SVN

Slide 42

Slide 42 text

Git Lifecycle

Slide 43

Slide 43 text

Git Lifecycle

Slide 44

Slide 44 text

The Staging Area (AKA The Index)

Slide 45

Slide 45 text

Branching

Slide 46

Slide 46 text

Text http://pcottle.github.io/learnGitBranching/?demo A cool demo

Slide 47

Slide 47 text

Branching

Slide 48

Slide 48 text

Branching

Slide 49

Slide 49 text

Branching - Merging (fast forward)

Slide 50

Slide 50 text

Branching - Deleting

Slide 51

Slide 51 text

Branching cont

Slide 52

Slide 52 text

Branching - Merging (3 way merge)

Slide 53

Slide 53 text

Branching - Management

Slide 54

Slide 54 text

Branching - Remote

Slide 55

Slide 55 text

Branching - Remote

Slide 56

Slide 56 text

Branching - Remote

Slide 57

Slide 57 text

Branching - Remote git pull == git fetch && git merge

Slide 58

Slide 58 text

Branching - Pushing Requires tracking

Slide 59

Slide 59 text

Deleting Remote Branches

Slide 60

Slide 60 text

Pull Requests

Slide 61

Slide 61 text

Creating a Pull Request 1 2 3 4

Slide 62

Slide 62 text

Reviewing a Pull Request

Slide 63

Slide 63 text

Merging Pull Request Online

Slide 64

Slide 64 text

Merging Pull Requests Offline •Resolve Conflicts •Test •Improve

Slide 65

Slide 65 text

Deleting Branch After PR Merge

Slide 66

Slide 66 text

Git Flow

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

1. Create a Branch git co -b bug-157 Branch Naming: bug-xxx! feature-yyy! wip-zzz

Slide 69

Slide 69 text

2. Add Commits Commit messages are super important!!!

Slide 70

Slide 70 text

3. Open a Pull Request Make sure you assign a reviewer!

Slide 71

Slide 71 text

4. Discuss AKA Code Review Continue to commit and push. This will be reflected

Slide 72

Slide 72 text

5. Merge Merge means: It’s good for production. master is always deployable

Slide 73

Slide 73 text

Pull Request Demo

Slide 74

Slide 74 text

Code Review

Slide 75

Slide 75 text

Code Review

Slide 76

Slide 76 text

Protips

Slide 77

Slide 77 text

Protip: How to transition your team from svn to git 1. Use git-svn, or Svn2git 2. Start using git “as svn” eg no branches 3. Start using branches and pull requests (if github) 4. Personal opinion: Use only CLI tools

Slide 78

Slide 78 text

Protip: git rebase -i

Slide 79

Slide 79 text

Protip: zsh integration

Slide 80

Slide 80 text

Protip: git stash

Slide 81

Slide 81 text

Extra

Slide 82

Slide 82 text

Conflicts

Slide 83

Slide 83 text

Conflicts Edit Collision # Edit file and then $ git add! $ git commit

Slide 84

Slide 84 text

Conflicts Removed File

Slide 85

Slide 85 text

Conflicts Removed File - Keep

Slide 86

Slide 86 text

Conflicts Removed File - Remove

Slide 87

Slide 87 text

Conflicts Git Mergtool • Not covered here... • http://git-scm.com/docs/git-mergetool

Slide 88

Slide 88 text

Conflicts While Rebasing

Slide 89

Slide 89 text

Learning More

Slide 90

Slide 90 text

Refs http://git-scm.com/about http://thkoch2001.github.io/whygitisbetter/ http://www.slideshare.net/manishchaks/subversion- to-git-migration http://www.git-tower.com/blog/git-for-subversion- users-cheat-sheet-detail/ http://git.or.cz/course/svn.html (or: where did I steal from?)

Slide 91

Slide 91 text

Refs https://help.github.com/articles/resolving-a-merge-conflict- from-the-command-line http://pcottle.github.io/learnGitBranching/ http://jeffkreeftmeijer.com/2010/the-magical-and-not- harmful-rebase/ https://help.github.com/articles/using-pull-requests https://help.github.com/articles/creating-a-pull-request http://en.wikipedia.org/wiki/ Coupling_(computer_programming)