Top Banner
59
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: martinwo@microsoft.com @martinwoodward  .
Page 2: martinwo@microsoft.com @martinwoodward  .

Martin Woodward Phil HaackPrincipal Program Manager Engineering ManagerMicrosoft GitHub

Using Git in Visual Studio

3-746

Page 3: martinwo@microsoft.com @martinwoodward  .

[email protected]

@martinwoodward

http://woodwardweb.com

http://radiotfs.com

Martin Woodward

Page 4: martinwo@microsoft.com @martinwoodward  .
Page 5: martinwo@microsoft.com @martinwoodward  .

Practices VisibilityGovernanceMentorshipSupportFeedback

MediaEventsSponsorship

Fostering a vibrant .NET ecosystem

ProtectionLicensesCopyrightsTrademarksPatents

dotnetfoundation.org

dotnet.github.io

@dotnetfdn

98 repositories13,189 forks2,290 contributors

Growing daily…

Openness.

Community.

Rapid innovation.

Page 6: martinwo@microsoft.com @martinwoodward  .

Openness

Community

Rapid innovation

The .NET Foundation

.NET API for Hadoop WebClient

.NET Compiler Platform ("Roslyn").NET Map Reduce API for Hadoop

.NET Micro Framework

ASP.NET MVCASP.NET Web API

ASP.NET Web Pages

ASP.NET SignalR

MVVM Light Toolkit

.NET Core 5

Orleans

MEF (Managed Extensibility Framework)

OWIN Authentication MiddlewareRx (Reactive Extensions)

Orchard CMSWindows Azure .NET SDK

Thinktecture IdentityManagerWnsRecipe

Mimekit Xamarin.Auth

Xamarin.Mobile

Couchbase for .NET

Meet the people behind the .NET Foundationhttp://www.dotnetfoundation.org/team

Join the conversation with the

community http://www.dotnetfoundation.org @dotnetfdn

Mailkit

System.Drawing

ASP.NET 5

Salesforce Toolkits for .NET

NuGetKudu Cecil

MSBuild

LLILC

Page 7: martinwo@microsoft.com @martinwoodward  .

tinyurl.com/proalm12

Page 8: martinwo@microsoft.com @martinwoodward  .

Phil Haack, GitHub

@haacked

Page 9: martinwo@microsoft.com @martinwoodward  .

Git fully integrated into Visual Studio, Visual Studio Online and TFS

Page 10: martinwo@microsoft.com @martinwoodward  .

Announcing…

GitHub fully integrated into Visual Studio 2015

Page 11: martinwo@microsoft.com @martinwoodward  .

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

Page 12: martinwo@microsoft.com @martinwoodward  .

Version control using Git with Visual StudioDemo

Page 13: martinwo@microsoft.com @martinwoodward  .

The Git repositoryDeep Dive

Page 14: martinwo@microsoft.com @martinwoodward  .

History

1 2 3

1 2 3 4

5

My repository

Bob’s repository

5

6

Page 15: martinwo@microsoft.com @martinwoodward  .

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

Page 16: martinwo@microsoft.com @martinwoodward  .

History Improvements in VS2015Demo

Page 17: martinwo@microsoft.com @martinwoodward  .

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

Page 18: martinwo@microsoft.com @martinwoodward  .

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

Page 19: martinwo@microsoft.com @martinwoodward  .

Author and Committer default data in Git Settings:

git config --global user.name “Martin Woodward“ git config --global user.email “[email protected]"

Git Settings

Page 20: martinwo@microsoft.com @martinwoodward  .

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

Best stored in the repo

Go to Git Repository Settings in Team Explorer to create a default one

Ignoring stuff with .gitignore

Page 21: martinwo@microsoft.com @martinwoodward  .

CommitsDemo

Page 22: martinwo@microsoft.com @martinwoodward  .

Branches

4d2460a 6d36faa

fc1de8e

56b1b9f8b58f71aab6f14

bobs

mine

HEAD

Page 23: martinwo@microsoft.com @martinwoodward  .

Branches

4d2460a 6d36faa

fc1de8e

56b1b9f8b58f71aab6f14

bobs

mine

HEAD

45dc20f

Page 24: martinwo@microsoft.com @martinwoodward  .
Page 25: martinwo@microsoft.com @martinwoodward  .
Page 26: martinwo@microsoft.com @martinwoodward  .

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

Page 27: martinwo@microsoft.com @martinwoodward  .

Tags

release-0.1

release-0.2

4d2460a 6d36faa

fc1de8e

8b58f71aab6f14

bobs

mine

HEAD

833831f

Page 28: martinwo@microsoft.com @martinwoodward  .

Tags

release-0.1

release-0.2

4d2460a 6d36faa

fc1de8e

8b58f71aab6f14

bobs

833831f

mine

HEAD

7bcf452

Page 29: martinwo@microsoft.com @martinwoodward  .

Branches & TagsDemo

Page 30: martinwo@microsoft.com @martinwoodward  .

MergesMerging two commits

4d2460a 6d36faa

fc1de8e

8b58f71aab6f14

bobs

mine

HEAD

Page 31: martinwo@microsoft.com @martinwoodward  .

MergesMerging two commits

4d2460a 6d36faa

fc1de8e

8b58f71aab6f14

bobs

mine

HEAD

833831f

Page 32: martinwo@microsoft.com @martinwoodward  .

MergesFast-forwards

4d2460a 6d36faa

fc1de8e

aab6f14

feature

master

HEAD

Page 33: martinwo@microsoft.com @martinwoodward  .

MergesFast-forwards

4d2460a 6d36faa

fc1de8e

aab6f14

feature

master

HEAD

Page 34: martinwo@microsoft.com @martinwoodward  .

RebaseRebasing a commit

4d2460a 6d36faa

fc1de8e

8b58f71aab6f14

bob

mine

HEAD

fc1de8e

Page 35: martinwo@microsoft.com @martinwoodward  .

RebaseRebasing a commit

4d2460a 6d36faa 8b58f71aab6f14

mine

HEAD

9cd3f8e

bob

4a1defe

Page 36: martinwo@microsoft.com @martinwoodward  .

RebaseRebasing a commit

4d2460a 6d36faa 8b58f71aab6f14

mine

HEAD

6cdf32a

bob

b9d3fe1

Page 37: martinwo@microsoft.com @martinwoodward  .

Merge, Rebase and dealing with conflicts in Visual Studio

Demo

Page 38: martinwo@microsoft.com @martinwoodward  .

Feature Branches and Pull Requests

4d2460a 6d36faa

fc1de8e

8b58f71aab6f14

my-feature

master

HEAD

Page 39: martinwo@microsoft.com @martinwoodward  .

Feature Branches and Pull RequestsMerge via Pull Request

4d2460a 6d36faa

fc1de8e

8b58f71aab6f14

my-feature

master

HEAD

833831f

PR12

Page 40: martinwo@microsoft.com @martinwoodward  .

• Use feature branches in a shared private repo

• Only merge to master via Pull Requests• Consider use of Code Policies with Pull

Requests

Working in a larger team

Page 41: martinwo@microsoft.com @martinwoodward  .

Using Pull Requests in Visual Studio OnlineDemo

Page 42: martinwo@microsoft.com @martinwoodward  .
Page 43: martinwo@microsoft.com @martinwoodward  .

http://langpop.corger.nl/

Page 44: martinwo@microsoft.com @martinwoodward  .
Page 45: martinwo@microsoft.com @martinwoodward  .
Page 46: martinwo@microsoft.com @martinwoodward  .
Page 47: martinwo@microsoft.com @martinwoodward  .
Page 48: martinwo@microsoft.com @martinwoodward  .

GitHub fully integrated into Visual Studio 2015

Page 49: martinwo@microsoft.com @martinwoodward  .

• Limited push access to shared repo• Fork the shared repo• Commit changes into Feature Branch• Create pull request

• Good practise for the committers of a large project to follow same workflow

Open Source Workflow

Page 50: martinwo@microsoft.com @martinwoodward  .

Using the Fork and Pull Request model

dotnet\coreClr

phil\coreClr

Page 51: martinwo@microsoft.com @martinwoodward  .

Installation

https://aka.ms/ghfvs

Page 52: martinwo@microsoft.com @martinwoodward  .

Installation

Page 53: martinwo@microsoft.com @martinwoodward  .

Installation

Page 54: martinwo@microsoft.com @martinwoodward  .

Using GitHub with Visual Studio 2015

Demo

Page 55: martinwo@microsoft.com @martinwoodward  .

What’s new for Git in VS 2015• 1st Class GitHub Integration (+ extensibility)• Git for Windows installed by default (RTM)• History Enhancements• Branch Enhancements• Rebase Support• Remotes management• Git Settings Enhancements• Performance (esp clone, checkout, fetch,

merge)

Page 56: martinwo@microsoft.com @martinwoodward  .

What’s new for Git in TFS 2015• Code Policies• Required Build (Gated Pull Request)• Minimum number of reviewers, specific code reviews based on file path

• Pull Requests• Integration with policies & builds• Lightweight States + Voting Enhancements

• Web Based File Editing• New History View (including Branch

Updates)• Team Project Rename• Performance

Page 57: martinwo@microsoft.com @martinwoodward  .

• Fill out your evals• Install VS 2015 RC today• Have a play with Git• Create a VSO Account• Create a GitHub Account• Contribute some code to an OSS project

Call to Action

Page 58: martinwo@microsoft.com @martinwoodward  .

Martin [email protected]@martinwoodward

Phil [email protected]@haacked

Thank you

Page 59: martinwo@microsoft.com @martinwoodward  .

© 2015 Microsoft Corporation. All rights reserved.