This are the slides of my Visug (Visual Studio User Group) session about how yo can leverage the power of Git with TFS 2013/Visual Studio online and Visual Studio.
4. Agenda
Source control in
general
Git with Visual Studio
Git on TFS or VisualStudio.com
Git with TFS Build
Git as deployment protocol
Git on TFS in Cross-platform environments
9. “SourceSafe gives you the illusion of safety
and control, while exposing your project to
risk”
“SourceSafe teaches developers bad habits
like: avoid branching, exclusive locks, easy
permanent deletions”
Codinghorror.com
10. Visual Studio 2005 Team System
Visual Studio 2008 Team System
Visual Studio Team Foundation Server 2010
TFVC
14. Server Workspaces
• You talk to TFS when you check-out
• Allows you to do security on check-out
• Visibility at all times into what everyone is doing
• Great for large codebases
17. Local Workspaces
• Default for TFS 2012
• No explicit checkout = easy to edit outside of
Visual Studio or Eclipse
• Get Latest & Check in Compares local cache
against the server
• Problematic for large codebases
18. Conclusion
Strengths
Best for
•
Scales to very large codebases
•
Large integrated codebases
•
Fine level permission control
•
•
Control and auditability over
source code down to the file level
Allows usage monitoring
•
Offline editing support
•
Medium-sized integrated
codebases
•
Easy to edit files outside Visual
Studio or Eclipse
•
A balance of fine-grained control
with reduced friction
19. If you really want TFVC
if (number of files > 100,000 ) || (locking = required)) {
return “consider server workspace”;
}
else {
return “consider local workspace”;
}
22. Modern Apps and OSS workflows
App Architecture: suite of loosely coupled
systems
Team: Written by small/discrete and distributed
Platforms: Multiple platforms and dev
environments (Windows, iOS, Android)
Open source components
26. Git took off
Git is the Leading DVCS Tool
Adoption of Git is growing exponentially
Git as a Deployment Protocol
Used to deploy web applications on many cloud
providers (Windows Azure, Heroku, Facebook)
Git has support across platforms
31. Team Foundation Server 2013 & Visualstudio.com
Git
100%
Visual Studio 2012 (+Tools for Git) & Visual Studio 2013
32. Git
Strengths
Best for
•
Full offline experience
•
Modular codebases
•
Complete repository with portable
history
•
Integrating with open source
•
Highly distributed teams
•
Simplified branching model
33. Team Foundation Server / VisualStudio online
Project 1
3rd Party
Project 2
Local
Repo
3rd Party
Other
Remote
Git Repo
55. Enterprise class support
Ease of installation
Support and servicing
Ease of management
Integrated Authentication
Enhanced permissions
ALM Integration
56. I want to..
In Visual Studio?
Command prompt
Get information about your
local repository (such as the
remotes you are tracking)
If the repository is in a TFS
team project, then yes.
Otherwise, no.
git-remote
No, but you can view them.
You can use the command
prompt to push, edit, and
remove tags.
Create or edit a note
No
You can use the command
prompt to push, edit, and
remove notes
Amend your last commit
No
git-commit
Undo a committed change by
applying the inverse of the
commit.
No
git-revert
Re-order history or combine
(squash) commits.
No
Rebasing
Apply a tag to a commit
58. When to Pick
TFVC
Git
• Developers familiar with
Centralized version control
• Developers want to use it
• Highly coupled codebase
• Tight audit/control
requirements
• Use of MyWork + Code Review
• Using tools with built-in Git
support
• XCode / iOS Development
In this session, it will all be about “source control”.. So if you don’t like source control, this is not the place to be
When you talk about source control models, you have 2 flavors:Centralized (who’s using..?)Distributed (who’s using..?)
Let me first start with a shield. Why? Well, when you are in one of the sides of this equitation, people tend to get fanatic about this. There are people saying “hell no, don’t use centralized, DSVC is the way to go!
Back in time.. Version control does exist already a long time.. There are like a dozen of tools and solutions available
Itwas good.. You had like one central “database” (on a fileshare)
“users” were complaining: http://www.codinghorror.com/blog/2006/08/source-control-anything-but-sourcesafe.html
TFVC was a follow-up from Visual Source Safe, but it was written from scratch (no link with SourceSafe) and uses a SQL Server database as a means of scaling to large environments and infrastructures.
Workspace: basically a mapping between a source control path and local file storage location.But you DO need the server.. You tell the server that you want to check-out files.. The server knows everything
There are lots of good things about server workspaces. Like exclusive locks, you know who’s editing which file
offline: you need to be connected to the server.. You tell the server what you want to do.. If the server is not available, you’re screwedRead-only: locks on a file.. You can manually remove those locks, but TFS will not know about themYou need visual studio!
Is this DVCS?NOPEThe server only has knowledge of a reference to a local workspace.. So it’s also a mapping!The local workspace links to file storage.. There is also something like $TF, where the information about your workspace is available
You need to talk to the server.. Because the server stores the history! The server is where permissions are controlled
App architecture is loosly coupled nowadays. There are a lot more frameworks to allow you to do that. You can have different pieces that are modular.For example, if I own a shop, Iwant to have a windows phone app, I could get it build by some guys at the other side of the world
Microsoft was also feeling those changes. They really needed to embrace this change to DVCS.
In fact, Git was built by Linus Torvalds for Linux kernel development in 2005. Mercurial was built by Mackall. the project Actually started a few days after Git.Mercurial got a lot more pressure to be a good product. It was getting more popular because there was more windows support. The reviews by the big players were good.
But something changed: Github. They changed the game! They made it as the leading DVCS!
- Very efficient model for deployment!- Git can read through HTTP and read and write through SSH. You push your code, John and Edward push their code, then whoever is in charge of deployment on your team will log onto the server and merge the code into the live environment. Git offers hooks, like “post-receive”, that can perform any kind of action you can throw together- You now have Git for Windows (thanks to Github), and many other tools on the windows platform
That made the decision for Microsoft easy, and they went for Git!
Before they started implementing Git, they had some principlesThey wanted to do it right.. Not Team Foundation Git!Actually even contributing to the community, and not cheating!
One of the main libraries that is used both on the client and on the server by both Microsoft and GitHub.Microsoft joined that project and have contributed to it.
This are the top 8 contributors of the project. And the bottom 2 guys are from Microsoft. direct commits from phkelley who has earned that access!Note that they started later that the other guys So they really joined the community.
As like the previous TFS versiosn, you can create a Team Project using TFVC.There’s source control provider.. In 2013, you can have a Git backend. Client has a source control providerYou can work local, or just clone another remote repo.There is also Git-TF. That way, you use centralized VC as ‘master’, and you can allow your teams to use Git, and than get that Git commits into TFVC.
VisualStudio.com -> Create new Team Projecthttps://github.com/mariorod/SeeGit to VisualStudio.comGit shell (typen)mkdir tempcd tempgit clone -mirror https://github.com/mariorod/SeeGit.gitcd .\SeeGit.git git push --mirror (xyz)Compared to --bare, --mirror not only maps local branches of the source to local branches of the target, it maps all refs (including remote branches, notes etc.) and sets up a refspec configuration such that all these refs are overwritten by a git remote update in the target repository.Web interface – loop everythingAdd a commentShare commit
Some basics, I will not show you any branching strategies etc.
Init: Initializes a git repository – creates the initial ‘.git’ directory Clone: Makes a Git repository copy from a remote source. Also adds the original location as a remote (use –mirror: replicate the state of an origin repository )Commit: Takes all of the changes written in the index, creates a new commit object pointing to it .. To the local repoFetch: Fetches all the objects from the remote repository that are not present in the local one. (updated the local copy of the remote repo)Pull: Fetches the files from the remote repository and merges it with your local one. (= git fetch & get merge)Push: Pushes all the modified local objects to the remote repository
You init a repo, you create a branch, you switch to the branch, you add commit, you switch branch and you merge + push
They used the libgit2..
Connecteren op die nieuwe ‘git’ repoDev-branch maken ( branches – new –dev – publish)Maak een wijziging in Settingsview.xml in de masterCommit + PushOpen web access – history – click op commitWijziging doen, zelfde lijntje op de dev branchCommit + PushMerge van dev-masterConflict resolving
There is something like “Team Explorer Everywhere”, by Microsoft, which is basically an Eclipse plugin that connects to to TFS.Version 2013 also adds some Git features. They did not build a “Git integration”, because of Egit, but they created some wizards
Maak een TFS build definitieToon settingsToon ookdat je git kuntgebruikenOpen eclipseToon TEEConnecteer op de git repo (via de ‘import’ wizard, alsonderdeel van TEE
It are all building blocks.. Use them as you like, combine what you like
Easy installation: really easy to create your own repo’s, private!Support: You can call Microsoft, and ask questionsEase of management: web interfaceIntegrated Authentication: NTLM support! Enhanced permissions (within web interface) –> on repo level!ALM integration: important: VS is only a part of the ALM cycle.
It’s a completely different product to its core!Now you have the power, the choice!The best for your team, for your product!It’s 100% git, if you don’t want to use it anymore, you can easily transform it to another Git provider
What’ really powerfull is the integration with the ALM features of TFS. You can use workitems, builds, …