Download - I'm lovin' git

Transcript
Page 1: I'm lovin' git

I’m lovin’ git

@ssaunier

Page 2: I'm lovin' git

Knowledge worker

We create and edit documents (text, images, etc.)

Page 3: I'm lovin' git

Everyday workflow

1. Create a file 2. Save it 3. Edit it 4. Save it again 5. etc.

Page 4: I'm lovin' git

File life

Page 5: I'm lovin' git

Manual version control

Page 6: I'm lovin' git

Can we automate this?

For each document version, we need to know

1. When the file was modified 2. What changed 3. Why it was modified

Page 7: I'm lovin' git

There’s more, teams

Page 8: I'm lovin' git

There’s more, teams

Page 9: I'm lovin' git

And one more question

For each document version, we need to know

1. When the file was modified 2. What changed 3. Why it was modified 4. Who did the change

Page 10: I'm lovin' git

In a nutshell

We want a tool which

1. tracks document version 2. keeps an history of document changes 3. foster team work

Page 11: I'm lovin' git
Page 12: I'm lovin' git

Set up

Download & install git at http://git-scm.com/

Page 13: I'm lovin' git

Your identity

$ git config --global user.name "Sebastien Saunier”$ git config --global user.email "[email protected]"$ git config -l

Page 14: I'm lovin' git

Basic commands

Page 15: I'm lovin' git

Starting

$ mkdir new_project$ cd new_project$ git init

Page 16: I'm lovin' git

Status

$ git status

git can tell you if your folder has some modified files (dirty)

Page 17: I'm lovin' git

Commit

snapshot of your work

Page 18: I'm lovin' git
Page 19: I'm lovin' git

How to commit?

# Select which file to add to the commit.$ git add <file_1_which_has_been_modified>$ git add <file_2_which_has_been_modified>

# Take a snapshot of what is in the staging area.$ git commit --message "A meaningful message about this change"

Page 20: I'm lovin' git

Diff

If git status tells you something changed, you can inspect exactly what changed:

$ git diff$ git diff <a_specific_file_or_folder>

Page 21: I'm lovin' git

Log

Show commit history with

$ git log

Page 22: I'm lovin' git

Branching

Page 23: I'm lovin' git

One feature = One branch

Page 24: I'm lovin' git

Diff

$ git branch my-feature

Page 25: I'm lovin' git

Diff

$ git checkout my-feature$ git commit (x2)

Page 26: I'm lovin' git

Diff

$ git checkout master$ git commit (x2)

In the meantime, one commit happened in the master branch

Page 27: I'm lovin' git

Merge

$ git checkout master$ git diff master..my-feature$ git merge my-feature

Page 28: I'm lovin' git

Clean up

$ git branch -d my-feature

Page 29: I'm lovin' git

Visualization

http://www.wei-wang.com/ExplainGitWithD3

Page 30: I'm lovin' git

Remote

Page 31: I'm lovin' git
Page 32: I'm lovin' git

We need a remote!

Go to GitHub, create a repo: https://github.com/new

$ git remote add origin [email protected]:<username>/<project>.git

Page 33: I'm lovin' git

Push

Share the code with your team, and the world

# Generic command$ git push <remote> <branch>

# What we'll use$ git push origin master

Page 34: I'm lovin' git

Pull

# Generic command$ git pull <remote> <branch>

# What we'll use$ git pull origin master

Page 35: I'm lovin' git

Github Desktop app

https://mac.github.com/

https://windows.github.com/

Page 37: I'm lovin' git

Repository page

lewagon/surfcamprails/rails

Examples

Page 38: I'm lovin' git

Repository page

lewagon/surfcamprails/rails

Examples

Page 39: I'm lovin' git

Profile page

Example: defunkt

Page 40: I'm lovin' git

Pull requests

Team workflow

Page 41: I'm lovin' git

Forks

Open source contribution

Page 42: I'm lovin' git

Github pages

Hosting your website for free!

Page 43: I'm lovin' git

Go furtherondemand.lewagon.org

Page 44: I'm lovin' git

Thank you!


Top Related