mastering git

48
Mastering Git www.staticvoidpodcast.com Chris Gomez @SpaceShot [email protected] www.chrisgomez.com

Upload: christopher-gomez

Post on 03-Mar-2017

117 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Mastering git

Mastering Gitwww.staticvoidpodcast.com

Chris Gomez@SpaceShot

[email protected]

Page 2: Mastering git

Mastering Git•Acquiring Git in Windows•How Git Works•Git “Verbs”•Git Tools•Using Git at Work•GitHub•Visual Studio Team Services

Page 3: Mastering git

Philly.NET Code Camp Friday•Workday for Microsoft•Morning: Bagels / Coffee / Drinks come to rooms•Lunch: Escorted to lunch line, eat in room•Snack: Pretzels / Drinks come to rooms•No room switching•Restrooms

Page 4: Mastering git

Acquiring Git#WindowsProblems

Page 5: Mastering git

…and more!

•Git for Windows•Posh-Git•GitHub Desktop•Visual Studio

Acquiring Git#WindowsProblems

Page 6: Mastering git

How Git Works

Page 7: Mastering git

What is Git Anyways?

Page 8: Mastering git

What is Git Anyways?

•“Distributed Version Control”•“Content Addressable File System”•“A Directed Acyclic Graph”

Page 9: Mastering git

How Git Works

•The Git Folder•The Git Internal Model•The Commit Graph

For now, let’s ignore the big phrases and focus on some easy concepts:

Page 10: Mastering git

The Git Folder

How Do You Create A Repository?

Page 11: Mastering git

Creating a Repositorymd .gitcd .gitmd objectsmd refsmd refs\headscopy con HEADref: refs/heads/master^Z

Page 12: Mastering git

Creating a RepositoryGit From The Bits Uphttps://www.youtube.com/watch?v=mdvlu_R8EWE

Page 13: Mastering git

Creating a Repository

git init

Just Kidding… use:

Page 14: Mastering git

The Git Internal Model

How Does Git Store Content?

Page 15: Mastering git

The Git Internal Model

For any value, Git simply creates a SHA1 hash, and that’s the key it uses to store the value

Page 16: Mastering git

git hash-object

echo Hello World | git hash-object –-stdin

61bf8b2fc819641b01d63266e72517b305608995

Page 17: Mastering git

Content Addressable File System

For all objects, from blobs to trees to commits, git cares about the content.

Page 18: Mastering git

.\

“saved code camps” favorite_codecamp.txt miami.txt

wisconsin.txt

.\code camps

The Commit Graph

philly.txt

Page 19: Mastering git

“saved code camps”

The Commit Graph

“second commit”favorite_codecamp.txt

philly.txt

wisconsin.txtmiami.txt

favorite_codecamp.txt

Page 20: Mastering git

Directed Acyclic Graph

A graph where points connect in one direction. There is no way to loop back to a point again.

Page 21: Mastering git

Git “Verbs”

Page 22: Mastering git

git init

•Lays git filesystem out in the current directory under .git subfolder•This is often hidden

Page 23: Mastering git

git add

• -n or –dry-run• -I –interactive

Page 24: Mastering git

git commit

Page 25: Mastering git

git branch

Page 26: Mastering git

So what are branches anyway?•Branches are sticky labels•They get moved around for you when you commit or do other actions.•Branches are REALLY basic

Page 27: Mastering git

git checkout

Page 28: Mastering git

What would it mean to rename a branch?

Page 29: Mastering git

git merge

Page 30: Mastering git

git tag

•Tags are just like branches •They are sticky labels•BUT they represent a moment in time•They do not get moved around for you

Page 31: Mastering git

Annotated Tags vs Lightweight

•Annotated Tags have metadata, including the “tagger”•Lightweight tags now more clearly defined as “temporary, private object labels”

Page 32: Mastering git

git rebase

Page 33: Mastering git

Rewriting History

Page 34: Mastering git

git clone

Page 35: Mastering git

GitTools

Page 36: Mastering git

Getting Away From Command Line#SoManyTools

• GitHub Desktop• GitKraken• SourceTree• Tower• SmartGit

Page 37: Mastering git

Default Editor

• Visual Studio Code: bit.ly/vscode_git

Page 38: Mastering git

GitHub

Page 39: Mastering git

Using Git at Work

Page 40: Mastering git

A Central Server

•Some repo will be considered “main”•Various methods of allowing access•Read Only, PR Everything• Team read/write•Many Possibilities

Page 41: Mastering git

A Central Server

•Good step towards a CI process•Build or deploy from a branch•Build from any branch?•Could choose to base versioning on tags

Page 42: Mastering git

On Site Repo

•Products you install and maintain•Gitlab•Bitbucket Enterprise•Github Enterprise•Visual Studio TFS (using git repos)

Page 43: Mastering git

In the cloud•GitHub•Gitlab•Bitbucket•Visual Studio Team Services•… and more

Page 44: Mastering git

Work strategy•Commit to master•Commit and merge feature branches•Feature branch and Pull Request•Fork and Pull Request•… and more

Page 45: Mastering git

Branching Strategies

• Infamous “Successful branching strategy” post• http://nvie.com/posts/a-successful-git-branc

hing-model/• http://drewfradette.ca/a-simpler-successful-

git-branching-model/

Page 46: Mastering git

Branching Strategies•Trunk Based Development• http://nvie.com/posts/a-successful-git-branc

hing-model/• “developers collaborate on code in a single

branch called ‘trunk’, resist any pressure to create other long-lived development branches”

Page 47: Mastering git

Commit Strategy

•History is sacred, commit as it lays•Shape history independently and present to team•Every commit is release ready code

Page 48: Mastering git

Visual Studio Team Services