deep dive into git with team foundation server

Post on 11-Feb-2017

228 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Martin Woodward Edward ThomsonPrincipal Program Manager Senior Software Engineer

Deep dive into Git with Team Foundation Server

3-590

martinwo@microsoft.com@martinwoodwardhttp://woodwardweb.comhttp://radiotfs.com

Martin Woodward

tinyurl.com/proalm12

ethomson@microsoft.com@ethomsonhttp://edwardthomson.com

Edward Thomson

We work hereand here

A comprehensive ALM offeringTeam

Foundation Service

Planning SCM Work Item Tracking Continuous Deployment Build Automation Feedback

Management

Centralized Version Control

(TFVC)

Strengths Best for

Modern source-control approaches

Server Workspaces

Local Workspaces

DistributedVersion Control (Git)

• Scales to very large codebases

• Fine level permission control• Allows usage monitoring

• Large integrated codebases• Control and auditability over

source code down to the file level

• Offline editing support• Easy to edit files outside

Visual Studio or Eclipse

• Medium-sized integrated codebases

• A balance of fine-grained control with reduced friction

• Full offline experience• Complete repository with

portable history• Simplified branching model

• Modular codebases• Integrating with open source• Highly distributed teams

Git fully integrated into Visual Studio and TFS

Fully integratedGit support

Team Foundation Server/ServiceProject 2

Issues

Project

MgmtBuild

Git SCC Provider

Project 1

Issues

Project

MgmtBuild

Git

3rd Party XCodeEclipseShell

3rd Party Eclipse

Shell… TFVC

……

TFS SCC Provider

Team Explorer

TFVC Object Model

Local Repo

LibGit2 / LibGit2Sharp

Other Remote

Git Repo

Git-TF

Version control using Git with Visual Studio and TFSDemo

Install Git for Windows Install PoshGit Install Windows Credential

Helper

Installing the perfect command linehttp://aka.ms/GitCL

Pick the middle one:

Tip: Installing Git for Windowsfriends don’t let friends use Git bash…

The Git repositoryDeep Dive

History

1 2 3

1 2 3 4

5

My repository

Bob’s repository

5

6

History is “flattened” to resemble output from regular git log

History in Visual Studio

How are commit IDs generated? Can’t be monotonically increasing without a server to arbitrate A cryptographic hash (SHA1) of the contents of the commit

History

1 2 3 4

5

64d2460a 6d36faa

fc1de8e

56b1b9f8b58f71aab6f14

CommitsContain meta-data

commit 4d2460a...

Parent commit: 6d36faa...

Author: Display Name <email@address.com> Timestamp

Committer: Display Name <email@address.com> Timestamp

CommitsRepresent the entire repository

\file1.txt

blob feb8b81... file1.txt

tree 09fc4b44...

commit 4d2460a...

\file1.txt\file2.txt

blob 095ee29... file2.txt

blob feb8b81... file1.txt

tree 1a58993...

commit 6d36faa...

Commits are immutable Since they are the hash of the contents, changing the content changes

the hash Create a new commit that contains the old data and the modifications

Commit amend Updates only the latest commit

Dangerous if you have published commits Other users are making changes based on that commit

Rewriting history

You can remove the ability to “force push” to TFSRestricting ability to push history re-writes

CommitsDemo

Author and Committer default to data in Git Settings:

git config --global user.name “Martin Woodward“ git config --global user.email “martinwo@microsoft.com"

Git Settings

gitignore file specifies which files get ignored from the repo by default

Best stored in the repo

Go to Git Settings in VS to create a default one

Ignoring stuff with .gitignore

Git configuration can be stored in the repo and be path specific using .gitattributes

Commonly controls Which files are treated as binary Merge strategies Line ending conversion

Git Attributes

git config --global core.autocrlf=true

A note on line endings

Git does not track renames Commits are a snapshot of the entire repository No additional metadata about deltas between commits

Git guesses renames Compare deleted files to added files Similar files are deemed “renames”

Heuristic approach to renames is more accurate than relying on user input.

Renames

Branches

4d2460a 6d36faa

fc1de8e

56b1b9f8b58f71aab6f14

bobs

mine

HEAD

Branches

4d2460a 6d36faa

fc1de8e

56b1b9f8b58f71aab6f14

bobs

mine

HEAD

45dc20f

BranchesDemo

Exist at the repository level A branch applies to the entire repository Unlike most centralized version control tools where branches

exist inside the repository

Exceptionally lightweight Implemented as a pointer to a commit in the graph Exist only in the local repository until they’re explicitly shared Encourages feature branching

Branches

MergesMerging two commits

4d2460a 6d36faa

fc1de8e

8b58f71aab6f14

bobs

mine

HEAD

MergesMerging two commits

4d2460a 6d36faa

fc1de8e

8b58f71aab6f14

bobs

mine

HEAD

833831f

MergesFast-forwards

4d2460a 6d36faa

fc1de8e

aab6f14

feature

master

HEAD

MergesFast-forwards

4d2460a 6d36faa

fc1de8e

aab6f14

feature

master

HEAD

Merging and dealing with conflicts in Visual StudioDemo

Based on pack filesOnly 3 methods: info_refs: What are the current branch pointers? receive_pack: Push upload_pack: Fetch

Bottlenecks. Generally limited by client bandwidth

Git protocol

TFS Git object data in SQLRepository Existence and Ownership

tbl_GitRepository (RepositoryId, Name, CreationDate, State, TeamProjectUri)

Git Ref Pointerstbl_GitRef (RepositoryId, Name, ObjectId, IsDefaultBranch)

Git Push Logtbl_GitPush (PushId, PusherId, PushTime)

Git Ref Logtbl_GitRefLog (PushId, Name, OldObjectId, NewObjectId)

Stored in SQL for on-premises TFS

In Visual Studio Online, stored in Azure Blob storage

TFS Git object data in SQL/Azure BLOB

Git is bad at certain things

Reorganize data to answer path questions Done by a job that runs on each push UI works without data until it is available

Index things like author, committer, change typesCache is fully re-buildableLink to work items on push in a low pri job

TFS solution: Metadata cache in SQL

Git is different Don’t force change on a team, give them choice Build out set of internal advocates and expertise via PoC’sCan use Git-TF or Git-SVN etc to migrate history Do you really need to migrate ALL history? Does the historical repo need to be the working one?If moving to Git, MOVE to GitFor large repos: Remove binary dependencies first (NuGet is your friend) Componentize code before migrating

Adopting Git

Options for users to access Visual Studio Online3) New cloud-only monthly user

plans

2) Included for MSDN subscribers

Mix & match: pick the right MSDN subscription or user plan for each team member’s needs. New monthly user plans can be used to complement teams of MSDN subscribers.

Increased value to existing and new MSDN subscribers. User plans purchased via Windows Azure.

1) Completely free for small teams

FREE: 5 users.FREE: 60 minutes Cloud Build per month.

FREE: 5 users.Additional users $20/month.

All users $45/month.Max 10 per account with this plan.Includes use of the VS Pro IDE.All users $60/month.

Choice in source code workflows Integrates the leading DVCS solution into the leading ALM suite Use centralized or distributed modes and always get the full integrated

ALM capabilities of TFS

Choice in development processes Pick Agile, CMMI, or Scrum processes or create your own Tooling to support best of breed practices regardless of your development

methodology

Choice in platforms Target the platform of your choice from the development environment of your

choice

Microsoft ALM supports choice

martinwo@microsoft.comethomson@microsoft.com@martinwoodward@ethomsonhttp://radiotfs.com

Thank you!

for MSDN Ultimate subscribers

Go to http://msdn.Microsoft.com/specialoffers

SPECIAL OFFERSPartner Program

Your Feedback is ImportantFill out an evaluation of this session and help shape future events. Scan the QR code to evaluate this session on your mobile device. You’ll also be entered into a daily prize drawing!

© 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Exist at the repository level A tag applies to the entire repository Unlike most centralized version control tools where tags

contain a subset of the repository

Similar to branches. Implemented as a pointer to a commit in the grap Exist only in the local repository until they’re explicitly shared

Tags

Tags

release-0.1

release-0.2

4d2460a 6d36faa

fc1de8e

8b58f71aab6f14

bobs

mine

HEAD

833831f

Tags

release-0.1

release-0.2

4d2460a 6d36faa

fc1de8e

8b58f71aab6f14

bobs

833831f

mine

HEAD

7bcf452

RebaseRebasing a commit

4d2460a 6d36faa

fc1de8e

8b58f71aab6f14

bob

mine

HEAD

RebaseRebasing a commit

4d2460a 6d36faa

fc1de8e e4e1fb3

aab6f14

bob

mine

HEAD

Sync with Visual StudioSync is the equivalent of: 1. fetch2. merge3. push

“Pushed By” tracked by TFS

top related