mastering git

Post on 03-Mar-2017

114 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Mastering Gitwww.staticvoidpodcast.com

Chris Gomez@SpaceShot

chris@chrisgomez.comwww.chrisgomez.com

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

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

Acquiring Git#WindowsProblems

…and more!

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

Acquiring Git#WindowsProblems

How Git Works

What is Git Anyways?

What is Git Anyways?

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

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:

The Git Folder

How Do You Create A Repository?

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

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

Creating a Repository

git init

Just Kidding… use:

The Git Internal Model

How Does Git Store Content?

The Git Internal Model

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

git hash-object

echo Hello World | git hash-object –-stdin

61bf8b2fc819641b01d63266e72517b305608995

Content Addressable File System

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

.\

“saved code camps” favorite_codecamp.txt miami.txt

wisconsin.txt

.\code camps

The Commit Graph

philly.txt

“saved code camps”

The Commit Graph

“second commit”favorite_codecamp.txt

philly.txt

wisconsin.txtmiami.txt

favorite_codecamp.txt

Directed Acyclic Graph

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

Git “Verbs”

git init

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

git add

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

git commit

git branch

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

git checkout

What would it mean to rename a branch?

git merge

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

Annotated Tags vs Lightweight

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

git rebase

Rewriting History

git clone

GitTools

Getting Away From Command Line#SoManyTools

• GitHub Desktop• GitKraken• SourceTree• Tower• SmartGit

Default Editor

• Visual Studio Code: bit.ly/vscode_git

GitHub

Using Git at Work

A Central Server

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

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

On Site Repo

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

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

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

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/

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”

Commit Strategy

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

Visual Studio Team Services

top related