Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Source Control The History of

Slide 3

Slide 3 text

Static Files The History of Source Control

Slide 4

Slide 4 text

FTP The History of Source Control

Slide 5

Slide 5 text

SFTP/SSH The History of Source Control

Slide 6

Slide 6 text

Centralized Version Control The History of Source Control

Slide 7

Slide 7 text

One Repository, Lots of Clients Centralized Version Control

Slide 8

Slide 8 text

CVS Centralized Version Control

Slide 9

Slide 9 text

SVN Centralized Version Control

Slide 10

Slide 10 text

Distributed Version Control The History of Source Control

Slide 11

Slide 11 text

Lots of Repos, Lots of Clients Distributed Version Control

Slide 12

Slide 12 text

Faster Distributed Version Control Benefits

Slide 13

Slide 13 text

No Internet No Problem Distributed Version Control Benefits

Slide 14

Slide 14 text

Inherit Backups Distributed Version Control Benefits

Slide 15

Slide 15 text

Mercurial (hg) Distributed Version Control

Slide 16

Slide 16 text

GIT Distributed Version Control

Slide 17

Slide 17 text

GIT Install

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

http://git-scm.com/ Install via package files. Available for Mac, Windows, Linux & Solaris Install - Option 1

Slide 20

Slide 20 text

http://windows.github.com/ Easiest way to install GIT on Windows Install - Windows Only

Slide 21

Slide 21 text

http://mxcl.github.com/homebrew/ Homebrew – package manager for OSX Install - Option 3 (Homebrew)

Slide 22

Slide 22 text

$ ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go) Step 1 Install - Option 3 (Homebrew)

Slide 23

Slide 23 text

$ brew install git Step 2 Install - Option 3 (Homebrew)

Slide 24

Slide 24 text

Config Settings

Slide 25

Slide 25 text

$ git config --global user.name "" Config Settings

Slide 26

Slide 26 text

$ git config --global user.email "" Config Settings

Slide 27

Slide 27 text

Workflow

Slide 28

Slide 28 text

Actual files you work on. Working Directory Workflow

Slide 29

Slide 29 text

Staging area. Index Workflow

Slide 30

Slide 30 text

Points to the last commit made. HEAD Workflow

Slide 31

Slide 31 text

New Repository

Slide 32

Slide 32 text

$ cd ~/Sites Make a New Repo

Slide 33

Slide 33 text

$ mkdir Make a New Repo

Slide 34

Slide 34 text

$ cd Make a New Repo

Slide 35

Slide 35 text

$ git init Make a New Repo

Slide 36

Slide 36 text

Clone Repository Copies an existing repository

Slide 37

Slide 37 text

$ cd ~/Sites Clone an Existing Repo

Slide 38

Slide 38 text

$ git clone https://github.com/ charlotte-front-end-developers/ git-tutorial.git Clone an Existing Repo

Slide 39

Slide 39 text

$ cd git-tutorial Clone an Existing Repo

Slide 40

Slide 40 text

Status Check

Slide 41

Slide 41 text

$ git status Status Check List all of the changes that have been made but not committed.

Slide 42

Slide 42 text

Add Changes

Slide 43

Slide 43 text

$ git add .txt Add Changes Adds an individual file and stores them in the Index until you’re ready to commit.

Slide 44

Slide 44 text

$ git add . Add Changes Add all changes.

Slide 45

Slide 45 text

Commit Changes

Slide 46

Slide 46 text

$ git commit -m “Message” Commit Your Changes Commits your changes and updates the HEAD.

Slide 47

Slide 47 text

Logs

Slide 48

Slide 48 text

$ git log Logs Lists the recent history of a repo.

Slide 49

Slide 49 text

$ git log --pretty=oneline Logs Lists the recent history of a repo in a slightly more readable format.

Slide 50

Slide 50 text

$ git log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short Logs Lists the recent history of a repo in an extremely more readable format.

Slide 51

Slide 51 text

$ git log --graph -- pretty=format:'%Cred%h%Creset - %C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an> %Creset'--abbrev-commit -- date=relative Logs Lists the recent history of a repo in an extremely more readable format.

Slide 52

Slide 52 text

Adding Remotes

Slide 53

Slide 53 text

$ git remote add origin Adding Remotes Useful for adding a remote to a new GIT repo.

Slide 54

Slide 54 text

$ git remote add Adding Multiple Remotes Creates another remote that you can pull and push too.

Slide 55

Slide 55 text

Push Changes

Slide 56

Slide 56 text

$ git push origin master Push Your Changes Pushes your changes to the remote. Typically a server or service like Github. Origin is an alias to a URL. Master is simply the default branch.

Slide 57

Slide 57 text

Pulling Changes

Slide 58

Slide 58 text

$ git pull origin master Pulling Changes A pull is two GIT commands in one. It will fetch changes from the remote, then attempt to merge them into your local repo.

Slide 59

Slide 59 text

Branches

Slide 60

Slide 60 text

$ git checkout -b Branches Creates a new branch.

Slide 61

Slide 61 text

$ git branch Branches Lists all branches.

Slide 62

Slide 62 text

$ git checkout Branches Change to your newly created branch.

Slide 63

Slide 63 text

$ git checkout master $ git merge Branches Merge a branch back into your master branch.

Slide 64

Slide 64 text

$ git push origin Branches Push your branch to the remote.

Slide 65

Slide 65 text

$ git branch -d Branches Delete a branch.

Slide 66

Slide 66 text

Revert Commits

Slide 67

Slide 67 text

$ git checkout -- Revert Commits Undo your changes to an individual file.

Slide 68

Slide 68 text

$ git checkout Revert Commits Detach you from what’s in HEAD.

Slide 69

Slide 69 text

$ git checkout -b Revert Commits Detach you from what’s in HEAD and create a new branch

Slide 70

Slide 70 text

$ git stash $ git reset --hard $ git stash pop Revert Commits Stash your current changes and then reset.

Slide 71

Slide 71 text

$ git reset --hard origin/master Revert Commits Scorched Earth.

Slide 72

Slide 72 text

Aliases

Slide 73

Slide 73 text

$ pico ~/.gitconfig Aliases Aliases are stored in a global .gitconfig file in your $HOME folder.

Slide 74

Slide 74 text

[alias] ci = commit cm = commit -am br = branch co = checkout lp = log -p who = shortlog -n -s --no-merges undo = reset --hard lc = log ORIG_HEAD.. --stat --no-merges lg = log --graph --pretty=format:'%Cred%h%Creset - %C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative lf = log --pretty=fuller cleanup = !git gc && git remote prune origin fork = remote add -f Aliases

Slide 75

Slide 75 text

$ git lg Aliases

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

Learn

Slide 78

Slide 78 text

http://try.github.io/ Learn