Академический Документы
Профессиональный Документы
Культура Документы
Git Repositories
Git and Azure Repos
Get feedback with pull requests
Set branch policies
Forks
Use this guide to sign up and start using Azure Repos. If you're new to Azure Repos, see What is Azure Repos?.
Azure DevOps Services includes free unlimited private Git repos, so Azure Repos is easy to try out. Git is the most
commonly used version control system today and is quickly becoming the standard for version control. Git is a
distributed version control system, meaning that your local copy of code is a complete version control repository.
These fully functional local repositories make it easy to work offline or remotely. You commit your work locally, and
then sync your copy of the repository with the copy on the server.
Git in Azure Repos is standard Git. You can use the clients and tools of your choice, such as Git for Windows, Mac,
partners' Git services, and tools such as Visual Studio and Visual Studio Code.
Start with Sign up and invite some teammates.
After you sign up, learn how to code with Git. Whether your code is in Azure Repos, in a GitHub repo, or on your
local computer, this guide shows you how to get started.
Other resources to get you up and running:
Web portal navigation
Security & identity
About projects and scaling your organization
Azure Repos is a set of version control tools that you can use to manage your code. Whether your software project is large or
small, using version control as soon as possible is a good idea.
Version control systems are software that help you track changes you make in your code over time. As you edit your code, you tell
the version control system to take a snapshot of your files. The version control system saves that snapshot permanently so you
can recall it later if you need it. Use version control to save your work and coordinate code changes across your team.
Even if you're just a single developer, version control helps you stay organized as you fix bugs and develop new features. Version
control keeps a history of your development so that you can review and even roll back to any version of your code with ease.
Azure Repos provides two types of version control:
Git: distributed version control
Team Foundation Version Control (TFVC ): centralized version control
Git
Git is the most commonly used version control system today and is quickly becoming the standard for version control. Git is a
distributed version control system, meaning that your local copy of code is a complete version control repository. These fully
functional local repositories make it is easy to work offline or remotely. You commit your work locally, and then sync your copy of
the repository with the copy on the server.
Git in Azure Repos is standard Git. You can use the clients and tools of your choice, such as Git for Windows, Mac, partners' Git
services, and tools such as Visual Studio and Visual Studio Code.
Connect your favorite development environment
Review code with pull requests
Protect branches with policies
Extend pull request workflows with pull request status
Isolate code with forks
IntelliJ
Leave comments
Branch permissions
Extend pull request workflows with pull request status
Pull requests and branch policies enable teams to enforce many best practices related to reviewing code and running automated
builds. But many teams have additional requirements and validations to perform on code. To cover these individual and custom
needs, Azure Repos offers pull request statuses.
Pull request statuses integrate into the PR workflow. They allow external services to programmatically sign off on a code change
by associating simple success/failure information with a pull request.
TFVC
Azure Repos also supports Team Foundation Version Control (TFVC ). TFVC is a centralized version control system. Typically, team
members have only one version of each file on their dev machines. Historical data is maintained only on the server. Branches are
path-based and created on the server.
Get started by creating a project, configuring your workspace, and reviewing and sharing your code. You can use any one of these
clients or IDEs:
Visual Studio
Xcode
Eclipse
Sign up for Azure DevOps to upload and share code in free, unlimited private Git repositories.
Then, connect to your favorite development tool like Eclipse, Xcode, Visual Studio, IntelliJ, or Android Studio to
work on apps anytime, anywhere.
If you don't have a Microsoft account, choose Create one. To learn more, see create a Microsoft account.
3. Enter your password and select Sign in.
An organization is created based on the account you used to sign in. Sign in to your organization at any time, (
https://dev.azure.com/{yourorganization} ).
You can rename and delete your organization, or change the organization location. To learn more, see the
following articles:
Rename an organization
Change the location of your organization
If you signed in with an existing Microsoft account, your next step is to Create a project. If you signed in with a
newly created Microsoft account, then your project is automatically created and named after your account name.
To learn more about managing projects, see Manage projects.
1. Select the sign-up link for Azure DevOps, Start free with GitHub. If you're already part of an Azure
DevOps organization, select Sign in to Azure DevOps.
2. Select Sign in with GitHub.
If you have an account in session already, select Use another account. You're taken to GitHub sign-in
where you can enter your GitHub user name or email address.
3. Enter your GitHub account credentials, and then select Sign in.
An organization is created based on the account you used to sign in. Sign in to your organization at any time, (
https://dev.azure.com/{yourorganization} ).
You can rename and delete your organization, or change the organization location. To learn more, see Manage
organizations.
Enable GitHub invitations
Creating a new Azure DevOps organization with your GitHub username turns on the Invite GitHub users policy
by default. For existing organizations, your administrator can turn on this capability via Organization settings >
Policies tab.
Once the setting is changed, sign out of Azure DevOps, and then from a fresh browser session, sign back in to the
organization dev.azure.com/{organizationName} or organizationName.visualstudio.com with your GitHub
credentials. You're now recognized as a GitHub user and the GitHub invitation experience is available to you.
NOTE
Add email addresses for personal Microsoft accounts and IDs for GitHub accounts unless you plan to use Azure
Active Directory (Azure AD) to authenticate users and control organization access. If a user doesn't have a Microsoft
or GitHub account, ask the user to sign up for a Microsoft account or a GitHub account.
After you create a new organization and team project in Azure DevOps Services, you can begin sharing your code
with others.
In this article, we'll show you how to start working with your code in Azure Repos with a simple walkthrough that
covers:
Installing Git command line tools
Cloning a Git repository
Working in a branch
Sharing your changes
Creating a pull request
2. Select Clone in the upper-right corner of the Files window and copy the clone URL.
3. Open the Git command window (Git Bash on Git for Windows) and browse to the folder where you want
the code from the repo stored on your computer. Run git clone followed by the path copied from the
Clone URL in the previous section, as shown in the following example.
Git downloads a copy of the code, including all commits and branches from the repo, into a new folder for
you to work with.
4. Switch your directory to the repository that you just cloned.
cd fabrikam-web
Keep this command window open, because you'll use it in the following steps.
1. From your web browser, open the team project for your organization and select the Code page. If you don't
have a team project, create one now.
2. Select Clone in the upper-right corner of the Code page and copy the Clone URL.
3. Open the Git command window (Git Bash on Git for Windows) and browse to the folder where you want
the code from the repo stored on your computer. Run git clone followed by the path copied from the
Clone URL in the previous section, as shown in the following example.
Git downloads a copy of the code, including all commits and branches from the repo, into a new folder for
you to work with.
4. Switch your directory to the repository that you just cloned.
cd SmartHotel360
Keep this command window open, because you'll use it in the following steps.
Work in a branch
Git branches isolate your changes from other work being done in the project. The recommended Git workflow
uses a new branch for every feature or fix that you work on.
Create branches by using the branch command. This command creates a reference in Git for the new branch and
a pointer back to the parent commit so Git can keep a history of changes as you add commits to the branch.
Git always adds new commits to the current local branch. Check what branch you're working on before you
commit so that you don't commit changes to the wrong branch.
Switch between local branches by using the checkout command. Git will change the files on your computer to
match the latest commit on the checked-out branch.
In this step, we'll create a working branch and make a change to the files on your computer in that branch.
Use the branch command to create the branch and checkout to switch to that branch. In the following example,
the new branch is named users/jamal/feature1 .
When you create a branch from the command line, the branch is based on the currently checked-out branch. If you
just cloned the repository, the default branch (typically master ) is checked out. Because you just cloned, your local
copy of master has the latest changes.
If you're working with a previously cloned repository, ensure that you have checked out the right branch (
git checkout master ) and that it's up to date ( git pull origin master ) before you create your new branch.
You can replace the first three commands in the previous example with the following command, which creates a
new branch named users/jamal/feature1 based on the latest master branch.
Switch back to the Git Bash window that you used in the previous section. Run the following commands to create
and check out a new branch based on the master branch.
Browse to the location of the repository on your local computer, make an edit to one of the files, and save it. If
you're adding code from your local computer to the repository, you can add it here by copying it to the folder
where you cloned the repository.
git add .
git commit -m "My first commit"
The git add . command stages your files, and git commit -m "My first commit" commits the staged files
with the specified commit message.
2. Push your changes to the Git repo on the server by entering the following command in the Git command
window:
Your code is now shared to the remote repository, in a branch named users/jamal/feature1 . To merge the code
from your working branch into the master branch, use a pull request.
2. Select Create a pull request in the upper-right corner of the Files window. If you don't see a message like
You updated users/jamal/feature1 just now, refresh your browser.
3. New pull requests are configured to merge your branch into the default branch, which in this example is
master . The title and description are pre-populated with your commit message.
You can add reviewers and link work items to your pull request.
You can review the files included in the pull request at the bottom of the New Pull Request window.
NOTE
This example shows the basic steps of creating and completing a pull request. To learn more about pull requests, including
voting and reviewing, commenting, autocomplete, and more, see Pull requests overview.
1. From your web browser, open the team project for your organization and select the Code page. If you don't
have a team project, create one now.
2. Select Clone in the upper-right corner of the Code page and copy the Clone URL.
3. Open the Git command window (Git Bash on Git for Windows) and browse to the folder where you want
the code from the repo stored on your computer. Run git clone followed by the path copied from the
Clone URL in the previous section, as shown in the following example.
Git downloads a copy of the code, including all commits and branches from the repo, into a new folder for
you to work with.
4. Switch your directory to the repository that you just cloned.
cd fabrikam-web
Keep this command window open, because you'll use it in the following steps.
Your changes are now merged into the master branch, and your users/jamal/feature1 branch is deleted on the
remote repository. To delete your local copy of the branch, switch back to your Git Bash command prompt and run
the following commands.
The git checkout master command switches you to the master branch. The git pull origin master command
pulls down the latest version of the code in the master branch, including your changes and the fact that
users/jamal/feature1 was merged. The git branch -d users/jamal/feature1 command deletes your local copy of
that branch.
Now you're ready to create a new branch, write some code, and do it again.
Here you'll find definitions of key concepts and artifacts used in Azure Repos.
Branch
Branches are lightweight references that keep a history of commits and provide a way to isolate changes for a
feature or a bug fix from your master branch and other work. Committing changes to a branch doesn't affect other
branches. You can push and share branches with other people on your team without having to merge the changes
into master.
Switching between branches is quick and easy. Git doesn't create multiple copies of your source code when you're
working with branches - it uses the history information stored in commits to re-create the files in a branch when
you start working on it.
Learn more: branches, branch organization, and how we use branches at Microsoft.
Branch policies
Branch policies are an important part of the Git workflow. You use them to help protect the important branches in
your development, like master . Branch policies enable you to:
Isolate work in progress from the completed work in your master branch.
Guarantee that changes build before they get to master.
Limit who can contribute to specific branches.
Enforce who can create branches and the naming guidelines for the branches.
Automatically include the right reviewers for every code change.
Enforce best practices with required code reviewers.
Learn more: branch policies.
Clone
Create a complete local copy of an existing Git repo by cloning it. Cloning a repo downloads all commits and
branches in the repo and sets up a named relationship with the existing repo that you cloned. Use this relationship
to interact with the existing repo, pushing and pulling changes to share code with your team.
Learn more: cloning.
Commit
A commit is a group of changes saved to your local repository. You can share these changes to the remote
repository by pushing.
Learn more: commits.
Fork
A fork is a complete copy of a repository, including all files, commits, and (optionally) branches. The new fork acts
as if someone cloned the original repository and then pushed to a new, empty repository. After a fork has been
created, new files, folders, and branches are not shared between the repositories unless a pull request carries them
along. When you're ready to share those changes, it's easy to use pull requests to push the changes back to the
original repository.
Learn more: forks
Git
Git is the most commonly used version control system today and is quickly becoming the standard for version
control. Git is a distributed version control system, so your local copy of code is a complete version control
repository. These fully functional local repositories make it is easy to work offline or remotely. You commit your
work locally, and then sync your copy of the repository with the copy on the server.
Git in Azure Repos is standard Git. You can use the clients and tools of your choice, such as Git for Windows, Mac,
partners' Git services, and tools such as Visual Studio and Visual Studio Code.
Learn more: Git and Azure Repos.
Git workflow
Version control has a general workflow that most developers use when writing code and sharing it with the team.
These steps are:
1. Get a local copy of code if they don't have one yet.
2. Make changes to code to fix bugs or add new features.
3. When the code is ready, make it available for your team to review.
4. After the code is reviewed, merge it into the team's shared codebase.
Git has a version of this workflow that uses terminology and commands such as repositories, branches, commits,
and pull requests. These terms might sound familiar if you've used a version control system like Team Foundation
Version Control (TFVC ) or Subversion, but they behave differently in Git.
1. Create a branch for the changes you plan to make and give it a name, such as users/jamal/fix-bug-3214 or
features/cool-feature .
2. Commit changes to your branch. People often have multiple commits for a bug fix or feature.
3. Push your branch to the remote repository.
4. Create a pull request so other people can review your changes. To incorporate feedback, you might need to
make more commits and push more changes. When the code is ready, complete the pull request and merge
your code into the target branch, such as master .
Use this workflow if you're new to Git. As your team gets more experienced and confident with Git, extend it to suit
your team's needs.
Learn more: how we use Git at Microsoft.
Notifications
With notifications, you receive an email when changes occur to work items, code reviews, pull requests, source
control files, and builds. For example, you can get notified whenever a bug that you opened is resolved, or when a
work item is assigned to you. You receive notifications based on rules or subscriptions made by you, for your
teams, or for the project. Learn more: About notifications.
Projects
A project, which was previously known as a team project, provides a repository for source code. A project provides
a place where a group of people can plan, track progress, and collaborate on building software solutions. A project
is defined for an Azure DevOps Services organization or within a TFS project collection. You can use it to focus on
those objects defined within the project. To learn more, see About projects and scaling your organization.
Public projects
A project created within an Azure DevOps Services organization that is visible to the whole world. Everyone in the
world can discover them and perform limited operations. Administrators can control who gets to fully contribute.
Administrators can switch a project from private to public, and vice-versa, as described in Change the project
visibility.
Pull request
Create pull requests to review and merge code in a Git project. Pull requests let your team review code and give
feedback on changes before you merge it into the master branch. Pull requests can come from either topic
branches within the same repository or a branch in a fork of the original repository. Reviewers can step through
the proposed changes, leave comments, and vote to approve or reject the code.
Learn more: pull requests.
Pull
A pull command updates the code in your local repository with the changes from other members of your team
that are in the remote repository.
Learn more: pull.
Push
Share changes made in commits and branches by using the push command.
When you push, Git uploads the saved commits in your checked branch to the remote repository. If the branch
exists on the remote repository, Git takes the commits and adds them to that branch on the remote repository. If
that branch doesn't exist, Git creates a new branch with the same commits as your local branch.
Learn more: push.
Repository
A repository is a location for your code managed by version control. Azure Repos supports both Git and TFVC.
Teams
A team corresponds to a selected set of project members. With teams, organizations can subcategorize work to
better focus on all the work they track within a project. Each team gets access to a suite of Agile tools. Teams can
use these tools to work autonomously and collaborate with other teams across the enterprise. Each team can
configure and customize each tool to meet their work requirements. To learn more, see About teams and Agile
tools.
5-Minute Quickstarts
Get started by creating a repo, uploading your code, and inviting developers to work in the repo. You can use any one of these
clients or IDEs:
Web
Visual Studio
Command-line
Xcode
Eclipse
IntelliJ
Or, you can import an existing repo from GitHub, Bitbucket, GitLab, or other location to a new, empty repo.
Videos
https://channel9.msdn.com/Events/Connect/2017/T178/player https://channel9.msdn.com/Events/Connect/2017/T184/player
Step-by-Step Tutorials
Learn the basics of working in Git with these tutorials which show tasks performed using Visual Studio or the command line.
Clone an existing repo
Save work with commits
Create work in branches
Share code with push
Update code with fetch and pull
Review code with pull requests
Review history
Concepts
Authentication
History in Git
Branch organization
Pull requests
Forks
Branch policies
Customize and extend pull request workflows with pull request status
How we use Git at Microsoft
Reference
Format comments with markdown
Command reference
Frequently asked questions
Resources
What is Git?
What is version control?
Plan your migration to Git
Migrate from TFVC to Git
Git at Scale
Marketplace extensions
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015
Host and manage your code in Git version control with Azure DevOps Services and Team Foundation Server. Use version control
to save your work and coordinate code changes across your team. Even if you're just a single developer, version control helps you
stay organized as you fix bugs and develop new features. Version control keeps a history of your development so that you can
review and even rollback to any version of your code with ease.
New to Git? Learn more about how Git and Azure Repos can help your team ship great code, and learn how we use Git at
Microsoft.
Get started
Connect your favorite development environment to Azure DevOps Services to access your repos and manage your work. Azure
DevOps Services IDE integrations are available for Visual Studio, Visual Studio Code, Eclipse, and IntelliJ.
New to Git? Learn how to share code with Git and Azure Repos with the following getting started guides:
Web
Visual Studio
Command-line
Xcode
Eclipse
IntelliJ
Git tutorial
Get up and running with Git and Azure Repos in just a few minutes with the Azure Repos Git quick start.
The Azure Repos Git tutorial walks you through Git tasks like creating repos, working in branches, saving your work, and sharing
your changes. Every task is presented step-by-step in Visual Studio or from the command line.
Review code
Review code with your team and make sure that changes build and pass tests before it's merged.
Leave comments
Branch permissions
Videos
https://www.youtube-nocookie.com/embed/J_DHkUKxI0E?start=0
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017
Branch policies are an important part of the Git workflow and enable you to:
Isolate work in progress from the completed work in your master branch
Guarantee changes build before they get to master
Limit who can contribute to specific branches
Enforce who can create branches and the naming guidelines for the branches
Automatically include the right reviewers for every code change
Enforce best practices with required code reviewers
Branch permissions
Branches tutorial
Learn more
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015
Azure DevOps Services and TFS projects contain Git repositories, work items, builds, and releases. You can use Git
repos in your projects to manage your source code as your project grows. This guide shows you how to create a
Git repo using the web portal for either Azure DevOps Services (hosted on Azure) or Team Foundation Server
(TFS - on-premises).
Prerequisites
An organization in Azure DevOps. If you don't have one, you can sign up for one for free. Each organization
includes free, unlimited private Git repositories.
Git command-line tools:
Install Git for Windows, which includes Git Credential Manager - Windows
Install Git for macOS and Linux.
For macOS and Linux, we recommend configuring SSH authentication
4. When you're happy with the repo name and choices, select Create.
A new empty Git repo is now created in your project.
If you created an empty repo (no README or .gitignore), you'll see instructions on how to clone the
repo to your computer or push code in an existing repo into the newly created one.
In this example you created a README and a .gitignore, so you'll see an overview of the files in your
repo, and you can clone the repo using the Clone link on the upper right of the page to get working
with a local copy of the repo immediately.
1. Navigate to your project by browsing to https://dev.azure.com/<your organization name> and selecting the
name of your project. You can select it from the All projects list, or from the Recent projects list at the top
if you have accessed it recently.
2. In the Project area in the web portal, select Code, then select the drop-down next to the current repo name
and choose New Repository.
3. In the Create a new repository dialog, verify that Git is the repo type and enter a name for your new repo.
You can also choose to add a README and create a .gitignore for the type of code you plan to manage in
the repo. A README contains information about the code in your repo, and a .gitignore file tells Git which
types of files to ignore, such as temporary build files from your development environment.
4. When you're happy with the repo name and choices, select Create.
A new empty Git repo is now created in your project.
If you created an empty repo (no README or .gitignore), you'll see instructions on how to clone the
repo to your computer or push code in an existing repo into the newly created one.
In this example you created a README and a .gitignore, so you'll see an overview of the files in your
repo, and you can clone the repo using the Clone link on the upper right of the page to get working
with a local copy of the repo immediately.
3. Open the Git command window (Git Bash on Git for Windows) and browse to the folder where you want
the code from the repo stored on your computer. Run git clone followed by the path copied from the
Clone URL in the previous section, as shown in the following example.
Git downloads a copy of the code, including all commits and branches from the repo, into a new folder for
you to work with.
4. Switch your directory to the repository that you cloned.
cd fabrikam-fiber
Keep this command window open, because you'll use it in the following steps.
1. Select Clone in the upper-right corner of the Code window and copy the Clone URL.
2. Open the Git command window (Git Bash on Git for Windows), navigate to the folder where you want the
code from the repo stored on your computer, and run git clone followed by the path copied from the
Clone URL in the previous step, as shown in the following example.
After running the previous command, Git downloads a copy of the code, including all commits and
branches from the repo, into a new folder for you to work with.
Keep this command window open, as you'll use it in the following steps.
cd fabrikam-fiber
4. Commit your changes by entering the following command in the Git command window:
When using git commit , -a means to commit all changed files, and -m specifies a commit message.
5. Push your changes up to the Git repo on the server by entering the following command into the Git
command window:
git push
6. Switch back to the web portal and select History from the Code view to view your new commit. The new
repo has two commits: the first commit where the README and .gitignore were added when the repo was
created, and the commit you just made.
7. Switch to the Files tab and click on the README file to view your changes.
Next steps
New to Git repos? Learn more
Learn more about using Git in the Git tutorial
Get started with Git from the command line
8/29/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015
This guide shows you how to share your code in a Git repo in Azure Repos using the command line.
The instructions below use the default bash shell used on Linux and macOS, but the Git commands will work in
any shell, including Git Bash from Git for Windows.
Prerequisites
An organization in Azure DevOps. If you don't have an organization, you can sign up for one for free. Each
organization includes free, unlimited private Git repositories.
Download and install Azure CLI and add Azure DevOps extension
1. Install the Azure CLI. You must have at least v2.0.49 , which you can verify with az --version command.
2. Add the Azure DevOps Extension az extension add --name azure-devops
cd /home/fabrikam/fiber
2. Create a Git repo on your machine to store your code. You will connect this repo to Azure Repos in the next
section.
git init .
2. Copy the clone URL from the remote URL attribute in the JSON output.
[
{
"defaultBranch": null,
"id": "fa3ee42f-519d-4633-8e31-4a84de343ca3",
"isFork": null,
"name": "FabrikamApp",
"parentRepository": null,
"project": {
"abbreviation": null,
"description": "This is the pipeline project for github repo",
"id": "fa3ee42f-519d-4633-8e31-4a84de343ca4",
"lastUpdateTime": "2019-04-09T08:32:15.977Z",
"name": "Fabrikam",
"revision": 255,
"state": "wellFormed",
"url": "https://dev.azure.com/fabrikops2/_apis/projects/fa3ee42f-519d-4633-8e31-4a84de343ca4",
"visibility": "public"
},
"remoteUrl": "https://dev.azure.com/fabrikops2/Fabrikam/_git/FabrikamApp",
"size": 0,
"sshUrl": "fabrikops2@vs-ssh.visualstudio.com:v3/fabrikops2/Fabrikam/FabrikamApp",
"url": "https://dev.azure.com/fabrikops2/fa3ee42f-519d-4633-8e31-
4a84de343ca4/_apis/git/repositories/fa3ee42f-519d-4633-8e31-4a84de343ca3",
"validRemoteUrls": null
}
]
3. Connect your local repo to the Git repo in Azure Repos using the copied clone URL in the git remote
command:
Next steps
New to Git repos? Learn more
Learn more about using Git in the Git tutorial
Share your code with Visual Studio 2017 and Azure
Repos Git
8/7/2019 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015
Share your Visual Studio solution in a new Azure DevOps Services or Team Foundation Server Git repo.
This article walks you through the steps to get a Visual Studio solution on your PC into a Git repo you can share
with others.
If you want to work with a Visual Studio solution hosted in an existing repo, see the Git tutorial.
Prerequisites
An organization in Azure DevOps. If you don't have an organization, you can sign up for one for free. Each
organization includes free, unlimited private Git repositories.
shows the number of unpublished commits in your local branch. Selecting this opens the
Synchronization view in Team Explorer.
shows the number of uncommitted file changes. Selecting this opens the Changes view in Team Explorer.
shows the current Git repo. Selecting this opens the Connect view in Team Explorer.
shows your current Git branch. Selecting this displays a branch picker to quickly switch between
Git branches or create new branches.
NOTE
If you don't see any icons such as or , ensure that you have a project open that is part of a Git repo. If your
project is brand new or not yet added to a repo, you can add it to one by selecting on the
status bar, or by right-clicking your solution in Solution Explorer and choosing Add Solution to Source Control.
3. Verify your email and select your account in the Team Services Domain drop-down.
4. Enter your repository name and select Publish repository.
This creates a new project in your account with the same name as the repository. To create the repo in an
existing project, click Advanced next to Repository name and select a project.
5. Your code is now in a Git repo in Azure Repos. You can view your code on the web by selecting See it on
the web .
3. Select the unpublished changes status bar icon (or select Sync from the Home view in Team
Explorer). Select Push to update your code in Azure DevOps Services/TFS.
Get changes from others
Sync your local repo with changes from your team as they make updates.
1. From the Synchronization view in Team Explorer, fetch the commits that your team has made. Double-
click a commit to view its file changes.
2. Select Sync to merge the fetched commits into your local repo and then push any unpublished changes to
Azure Repos.
3. The changes from your team are now in your local repo and visible in Visual Studio.
Work items can be included in commits by adding #ID into the commit message. For example,
Fixing bug #23 in the reporting tools would link work item 23 to the commit. The work item is linked when the
commit is pushed to Azure Repos.
Can I use the Git command prompt with Visual Studio?
Visual Studio's Team Explorer and the Git command line work great together. Changes to your repos made in
either tool will be reflected in the other. Make sure to install the latest release of Git for Windows, which has tools
to help you connect to your Azure DevOps Services/TFS repos.
See the Azure Repos Git tutorial and the command reference for additional help using Git from the command line.
Next steps
New to Git repos? Learn more
Checkout more steps in the Git workflow
Azure Repos Plugin for IntelliJ IDEA and Android
Studio
8/7/2019 • 7 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015
IntelliJ IDEA is an IDE produced by JetBrains. You can find out more about it at https://www.jetbrains.com/idea/.
The Azure Repos Plugin for IntelliJ allows you to connect to your Git repositories on Azure DevOps Services and
Team Foundation Server (TFS ) in a seamless and intuitive way. You can also use this plugin to import projects into
Azure Repos or create pull requests in your Azure DevOps Services/TFS Git repository.
In this guide, we show you how to create a Git repo using the Azure DevOps Services web portal, add some
sample code, and then clone the repo and create pull requests all from within IntelliJ IDEA.
Prerequisites
To complete the steps in this guide you need:
An organization in Azure DevOps. If you don't have an organization, you can sign up for one for free. Each
organization includes free, unlimited private Git repositories.
IntelliJ IDEA installed on your machine. If you don't have it, get IntelliJ IDEA.
The Azure Repos plugin for IntelliJ. See IntelliJ Plugin download page for installation instructions. This plugin
is compatible with IntelliJ IDEA Ultimate and Community editions, Android Studio, RubyMine, WebStorm,
PhpStorm, PyCharm, AppCode, MPS, 0xDBE, and CLion.
Git command line tools.
To install Git for Windows, including Git Credential Manager, see Install the Git Credential Manager -
Windows.
To install Git for macOS and Linux, see Install the Git Credential Manager - macOS and Linux.
Create a repo
1. Navigate to your project in Azure DevOps by browsing to https://dev.azure.com/{your organization} and
selecting the name of your project. You can select it from the All projects list, or from the Recent projects
list if you have accessed it recently.
NOTE
Project URLs have changed with the release of Azure DevOps Services and now have the format
dev.azure.com/{your organization}/{your project} , but you can still use the existing visualstudio.com
format. For more information, see VSTS is now Azure DevOps Services.
2. In the Project area in the web portal, select Code, then select the drop-down next to the current repo name
and choose New Repository.
3. In the Create a new repository dialog, verify that Git is the repo type, enter DeepSpace for your new
repo name, and click Create.
Add sample code to your repo
1. Select Clone in the upper-right corner of the Code window and copy the Clone URL.
2. Open the Git command window (Git Bash on Git for Windows), navigate to the folder where you want the
code from the repo stored on your computer, and run git clone followed by the path copied from the
Clone URL in the previous step, as shown in the following example.
cd DeepSpace
You may see some warnings stating the line feeds will be replaced with carriage return line feeds (i.e.
Warning: LF will be replaced by CRLF ). These warnings can be ignored.
6. Commit the files to the local repo by running the following command.
7. Run the following command to push the commit of DeepSpace sample files up to your Azure Repos
DeepSpace repo.
git push
8. Switch back to the Azure DevOps Services web portal and refresh, and you can see the files that were
added.
3. When you click Sign in, you will be presented with the standard Azure DevOps Services sign in UI. Once
signed in, you should see the list of all repositories you have access to on Azure DevOps Services. Choose
the correct repo, DeepSpace, and click the Clone button. (You may also want to choose where on your
hard drive the repo is cloned to by changing the Parent Directory.)
4. After the clone finishes, IntelliJ will ask you if you want to open the project. Click Yes and you should end
up with the DeepSpace project opened in IntelliJ IDEA.
Let's fix this section of code locally. Typically, when working in a Git repo, you should create a branch for
your work and commit to that branch. Create a branch through IntelliJ using the built-in VCS > Git >
Branches window. When prompted, use the branch name fixBugs. Once we have a branch to make our
changes in, we can uncomment the code and rebuild the project. If you follow the instructions above to run
the program again, you should see the Earth fly by.
3. Now that our changes are built and tested, we can commit them locally using the VCS > Commit
Changes menu. In the commit dialog, you will see a VSTS button above the commit message text box.
Click on that button to view your list of work items assigned to you. Select the Add Missing Earth work
item and click OK. You will see the commit message text box populate with the work item's type, number,
and title. This will associate the work item to this commit for traceability in the future.
Note that this change is only done locally; it hasn't been changed in our Azure DevOps Services repo yet.
You can click on the icon for more options such as viewing build details, queuing a new build, and updating the
status manually.
View Pull Requests and Work Items
Under the Version Control menu, a Pull Request tab and Work Items tab exist to allow you to easily view the
information you need without leaving the IDE. The Pull Request tab shows you the current pull requests created
by you and assigned to you along with their status. The tab also gives you the ability to create and/or abandon pull
requests.
Under the Work Items tab, you can view the work items based on queries that you have created or use the
default query to see work items that are assigned to you. You can also create a branch based off of a work item so
that you can associate a work item with branch for future traceability purposes.
Next Steps
Check out the entire DeepSpace IntelliJ tutorial
View the IntelliJ plugin FAQ
Share your code in Git using Xcode
8/7/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015
This guide shows you how to share your Xcode projects using Azure Repos.
Prerequisites
An organization in Azure DevOps. If you don't have an organization, you can sign up for one for free. Each
organization includes free, unlimited private Git repositories.
Existing projects
Create a local Git repo for your existing projects not in version control by going to Source Control, Create
Working Copy... . Select the projects to add to the local Git repo and select Create. Xcode creates a Git repo for
your code and adds a commit with your project files.
NOTE
If you want to use SSH to connect to your Azure Repos/TFS Git repo, Set up SSH credentials and use the SSH clone
URL when adding the remote for your local Git repo.
2. Select Remotes, then select the icon and choose Add Remote...
3. In the Address field, paste the Git clone URL for your repo copied in the previous step. Select Add
Remote, then select Done to finish creating the origin remote for your local Git repo.
4. Go to Source Control, Push..., enter the branchname on origin to push to, and select Push.
5. If prompted, enter your Azure DevOps Services credentials. For Username, enter your Azure DevOps
Services username. For Password, enter a Personal Access Token created for your user in VSTS. Select OK.
Xcode will push your project to your Azure Repos/TFS Git repo so you can share it with your team.
Next steps
Learn more about using Git in the Git tutorial
Share your code in Git using Eclipse
8/7/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015
Share your Eclipse project with your team in an Azure DevOps Services/TFS Git repo.
Prerequisites
An Azure DevOps organization. If you don't have one, you can sign up for one for free. Each organization
includes free, unlimited private Git repositories.
A local Eclipse project. If your code is already in version control in Azure Repos or TFS and you want to clone it,
see Clone an Azure DevOps Services Git repo using Eclipse.
NOTE
The Team Explorer Everywhere plug-in works with Eclipse versions 4.2 (Juno) - 4.6 (Neon).
Either choice will prompt for your credentials before continuing further.
3. Select the project where you will share your code from the Project Selection dialog and select Finish.
NOTE
If your code is already in a local Git repo, you can skip this step.
1. With your project open in Eclipse, right-click the project name in Project Explorer and select Team, Share
Project... Select Git and select Next.
2. Select Create... from the Configure Git Repository window and choose a folder for your local Git repo.
Select Finish.
3. Right-click your project in Project Explorer and select Team, Commit.... Stage your changes by dragging
your files to the Staged Changes field, enter a commit message, then select Commit.
3. Review the changes and select Finish in the Push Branch window.
Your project code is now in your Git repo.
Troubleshooting
What if the Git views for commit and push don't show up?
You can download EGit to use Git with Eclipse.
Next steps
Learn more about using Git in the Git tutorial
Import a Git repo
8/27/2019 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | TFS 2013
This guide shows you how to import an existing Git repo from GitHub, Bitbucket, GitLab, or other location into a
new or empty existing repo in your project in Azure DevOps.
IMPORTANT
The Import repository feature is currently not working if you are importing a GitHub repo using TFS 2017.1 to TFS 2018.1.
For more information about this issue, see Weak cryptographic standards removal notice and Unable to connect to GitHub
due to TLS 1.2 only change
On your Application Tier servers, you can modify the web.config file to change the targetFramework from
<httpRuntime targetFramework="4.5" to <httpRuntime targetFramework="4.6" .
This issue is resolved starting with Team Foundation Server 2018 Update 2 RC1 and higher.
Prerequisites
An organization in Azure DevOps. If you don't have one, you can sign up for one for free. Each organization
includes free, unlimited private Git repositories.
To use the Import repository feature in TFS, you must have TFS 2017 Update 1 or higher.
To import a repository using TFS 2017 RTM or earlier, see Manually import a repo.
3. If the source repo is publicly available, just enter the clone URL of the source repository and a name for
your new Git repository.
If the source repository is private but can be accessed using basic authentication (username-password,
personal access token, etc.), select Requires authorization and enter the your credentials. SSH
authentication is not supported, but you can manually import a repository that uses SSH authentication by
following the steps in Manually import a repo.
From the repo drop-down, select Import repository.
If the source repo is publicly available, just enter the clone URL of the source repository and a name for your new
Git repository.
If the source repository is private but can be accessed using basic authentication (username-password, personal
access token, etc.), select Requires authorization and enter the your credentials. SSH authentication is not
supported, but you can manually import a repository that uses SSH authentication by following the steps in
Manually import a repo.
2. Create a target repo using TFS 2017 RTM, and make a note of the clone URL. In this example,
https://dev.azure.com/contoso-ltd/MyFirstProject/_git/new-contoso-repo is the URL for the new target
repo.
3. Run the following command to copy the source repo to the target repo.
4. If the source repository has LFS objects then fetch them, and copy them from the source repo to the target
repo.
git lfs fetch origin --all
git lfs push --all https://dev.azure.com/contoso-ltd/MyFirstProject/_git/new-contoso-repo
cd ..
rm -rf old-contoso-repo.git
Next steps
New to Git repos? Learn more
Learn more about Git in the Git tutorial
Azure Repos Git tutorial
8/7/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015
Use version control to save your work and coordinate code changes across your team. Even if you're just a single
developer, version control helps you stay organized as you fix bugs and develop new features. Version control
keeps a history of your development so that you can review and even rollback to any version of your code with
ease.
The steps in the following tutorials show how to perform common version controls tasks using the following
version control workflow.
Git has a version of this workflow using terminology and commands unique to Git. Throughout this tutorial
you'll learn about repositories, branches, commits, and pull requests. These terms might sound familiar if you've
used a version control system like Team Foundation Version Control or Subversion, but they behave differently
in Git.
Git workflow
1. Create a branch for the changes you plan to make and give it a name, such as users/jamal/fix-bug-3214 or
cool-feature-x . For more branching guidance, see Adopt a Git branching strategy
2. Commit changes to your branch. People often have multiple commits for a bug fix or feature.
3. Push your branch to the remote repository.
4. Create a pull request so other people can review your changes. To incorporate feedback, you might need to
make more commits and push more changes.
5. Complete your pull request and resolve any merge conflicts from changes other people made after you
created your branch.
Use this workflow if you're new to Git. As your team gets more experienced and confident with Git, extend it to
suit your team's needs.
Next steps
Create a new Git repository
Clone an existing Git repository
Get Started with Azure Repos and Visual Studio
8/7/2019 • 7 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017
This guide covers the basics so you can get up and running using Git with code already in Azure DevOps Services
or Team Foundation Server (TFS ). Explore our full tutorial for more information on how to use Git from Visual
Studio or the command line.
If you don't have your code in an Azure DevOps Services or TFS Git repo, visit our Visual Studio or command line
getting started articles to learn how to create a local repo for your code and push it to Azure Repos.
2. On the Connect to a Project dialog, select the repo you want to clone from the list and select Clone. If
you don't see your repo listed, you can filter the list to find it or add a Team Foundation Server where the
repo is hosted by selecting the Add TFS Server link.
NOTE
Project URLs have changed with the release of Azure DevOps Services and now have the format
dev.azure.com/{your organization}/{your project} , but you can still use the existing visualstudio.com
format. For more information, see VSTS is now Azure DevOps Services.
3. Verify the location of the cloned repo on your PC and select Clone.
4. Make changes to your files in the cloned repo. From the Team Explorer Home view, you can open up
Visual Studio solutions in the repo or browse the repo contents using the Show Folder View link. Git
keeps track of changes made to your code both inside and outside of Visual Studio.
5. When you are satisfied with the changes, save them in Git using a commit. Open up the Changes view
from Team Explorer by selecting the Home icon and choosing Changes.
You can also navigate to the Synchronization view from the Changes view by choosing Sync
immediately after making a commit.
If this is your first push to the repository you'll see the following message in place of the outgoing commits
list:
The current branch does not track a remote branch. Push your changes to a new branch on the origin
remote and set the upstream branch.
Select Push to push your changes to a new branch on the remote repository and set the upstream branch.
The next time you push changes you'll see the list of commits.
3. Create a pull request so that others can review your changes. Open Pull Requests in Team Explorer by
selecting the Home icon and choosing Pull Requests.
4. From the Pull Requests view you can view pull requests opened by you, assigned to you, and you can
create new pull requests. Select New Pull Request to open up a web browser where you can create the
new pull request in the Azure DevOps Services web portal.
5. Verify your branches (in this example we want to merge the commits from the ReadMeFix branch into the
master branch), enter a title and optional description, specify any reviewers, optionally associate any work
items, and select Create.
For more information on pull requests, see the pull request tutorial.
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 Update 2
A Git repository, or repo, is a folder that you've told Git to help you track file changes in. You can have any number
of repos on your computer, each stored in their own folder. Each Git repo on your system is independent, so
changes saved in one Git repo don't affect the contents of another.
A Git repo contains every version of every file saved in the repo. Git saves these files very efficiently, so having a
large number of versions doesn't mean that it uses a lot of disk space. Storing each version of your files helps Git
merge code better and makes working with multiple versions of your code quick and easy.
In this tutorial you learn how to:
Create a new Git repo
Video tutorial
The following video explains what Git repos are, and shows you how to create them on your computer using
Visual Studio 2015 Update 2.
https://channel9.msdn.com/series/Team-Services-Git-Tutorial/Git-Tutorial-Create-a-Git-repo-in-Visual-Studio-
2015/player
TIP
Working from the command line? You can view our video overview using command line steps on Channel9.
In an empty folder
1. Open the Connect view in Team Explorer by choosing Projects then Manage Connections from the
context menu.
2. Under Local Git Repositories, select New and enter a folder where the repo will be created. This directory
must be empty.
3. Select Create to create the repo.
Next steps
Save work with commits
Clone an existing Git repo
5/31/2019 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015
Create a complete local copy of an existing Git repo by cloning it. Cloning a repo downloads all commits and
branches in the repo and sets up a named relationship with the existing repo you cloned. Use this relationship to
interact with the existing repo, pushing and pulling changes to share code with your team.
NOTE
By default, Git will assign the origin to the remote repo you clone from. Most users don't need more than one remote,
so the tutorial uses origin in its steps. Learn more about setting up remotes to your Git repo.
Video tutorial
https://channel9.msdn.com/series/Team-Services-Git-Tutorial/Git-Tutorial-Create-a-Git-repo-in-Visual-Studio-
2015/player
TIP
Working from the command line? You can view our video overview using command line steps on Channel9.
If you need to clone a GitHub repo, you'll need to get the clone URL from the Clone or download button while
viewing the repo on the web in GitHub.
Other Git providers have similar buttons in their user interface to get the clone URL.
Copy this URL into the clipboard or store it in a place where you can find it easily. You can't clone a repo without
a clone URL.
Clone a repo
Visual Studio
Command Line
Clone from Azure DevOps Services / Team Foundation Server
Clone from another Git provider
Open a solution in Visual Studio from a cloned repo
Clone from Azure DevOps Services / Team Foundation Server
1. In Team Explorer, open up the Connect page by selecting the Connect icon, and then choose Manage
Connections, Connect to Project.
2. On the Connect to a Project dialog, select the repo you want to clone from the list and select Clone. If
you don't see your repo listed, you can filter the list to find it or add a Team Foundation Server where the
repo is hosted by selecting the Add TFS Server link.
NOTE
Project URLs have changed with the release of Azure DevOps Services and now have the format
dev.azure.com/{your organization}/{your project} , but you can still use the existing visualstudio.com
format. For more information, see VSTS is now Azure DevOps Services.
3. Verify the location of the cloned repo on your PC and select Clone.
Clone from another Git provider
If you are not using Azure Repos, you can still clone your repo in Team Explorer and work with your code in
Visual Studio.
1. In Team Explorer, open the Connect view.
2. Select Clone under Local Git Repositories and enter the URL for your Git repo—this will be provided
by your team or Git hosting provider.
3. Select a folder where you want your cloned repo to be kept.
4. Select Clone to clone the repo.
Next steps
Save work with commits
Save work with commits
8/7/2019 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 Update 2
Git does not automatically snapshot your code as you make edits to files in your repo. You must tell Git
exactly which changes you want to add to the next snapshot by staging those changes. After staging your
changes, create a commit to save the snapshot to your repo.
In this tutorial you learn:
How Git tracks changes
What's in a commit
How to stage your changes
How to create a commit
How to update your last commit
When you create a commit, only the staged changes and unchanged files are used for the snapshot.
Changes to unstaged but modified files are kept, but the commit uses the unmodified version from the
previous commit in its snapshot.
Commits are created in your local Git repository, so you don't have to worry about your changes being
perfect. Continue to create commits as you work, pushing your changes to the team when they are ready to
share.
Video overview
https://channel9.msdn.com/series/Team-Services-Git-Tutorial/Git-Tutorial-Commits/player
What's in a commit
Commits include the following information:
A snapshot of the files saved in the commit. Git snapshots the contents of all files in your repo at the time
of the commit—this makes switching versions very fast and helps Git merge changes.
A reference to the parent commit(s). Commits with multiple parents occur when branches are merged
together.
A short and to the point message describing the changes in the commit. You enter this message when
you create the commit.
Git uses the references between commits along with the file snapshots to maintain a complete record of
development in your repo.
Learn more about Git history and how to review history to investigate changes made to your code.
Stage multiple files or folders by selecting them then right-clicking and choosing Stage or by dragging and
dropping files from the Changes list into the Staged Changes list.
Ignore files by right-clicking and selecting Ignore this local item or Ignore this extension. This adds an
entry to the .gitignore file in your local repo. If the ignored file was added to your repo in an earlier commit,
ignoring the file will not remove it from the Changes list. See excluding and ignoring files section for more
information on how to ignore files already tracked by Git.
Create a commit
Visual Studio
Command Line
Open the Changes view in Team Explorer.
Enter a commit message describing your changes and select Commit Staged to create a new commit that
includes the changes listed in the Staged Changes section.
Skip staging files if you just want to commit all changes listed by entering a commit message and selecting
Commit All when you have no staged changes.
When you commit in Visual Studio you can push the commit and sync the branch with a remote repository.
These options are available in the drop-down on the Commit button.
WARNING
Do not amend pushed commits. If you need to update pushed code, undo the changes with revert or create and
push another commit.
Visual Studio
Command Line
1. Open the Changes view in Team Explorer and stage your updated changes. You can amend just the
commit message by leaving the staged changes empty.
2. Enter the updated commit message and select Amend Previous Commit from the Actions drop-
down.
Next steps
Create work in branches.
Create work in branches
8/7/2019 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015
Git branches aren't much more than a small reference that keeps an exact history of commits, so they are
very cheap to create. Committing changes to a branch will not affect other branches, and you can share
branches with others without having to merge the changes into the main project. Create new branches to
isolate changes for a feature or a bug fix from your master branch and other work.
Since the branches are lightweight, switching between branches is quick and easy. Git does not create
multiple copies of your source when working with branches—it uses the history information stored in
commits to recreate the files on a branch when you start working on it. Your Git workflow should create and
use branches for managing features and bugfixes. The rest of the Git workflow, such as sharing code and
reviewing code with pull requests all work through branches. Isolating work in branches makes it very simple
to change what you are working on by simply changing your current branch.
In this tutorial you learn:
How are Git branches created?
How to create a branch
How to delete a branch
How to use branches
Video Overview
https://channel9.msdn.com/series/Team-Services-Git-Tutorial/Git-Tutorial-Branches/player
In this image, a new branch is created from the main branch. Work continues on both branches and commits
are added to both branches.
Git always adds new commits to the current local branch. Check what branch you are working on before you
commit so that you don't commit changes to the wrong branch. Swap between local branches using the
checkout command. Git will change the files on your computer to match the latest commit on the checked
out branch. When your work in the branch is ready to share with the rest of the team, you push the changes
to update the remote branch.
A common mistake is to make some changes and commit them, realize you are on an incorrect branch, then
checkout to the correct branch. Your most recent changes will no longer be on the filesystem since each
branch has its own version of code. Git will bring the state of the files back to the last commit on the branch
you swapped into, not the previous branch where you made your changes. You'll need to either cherry-pick
the commits from the branch or merge the changes into the correct branch.
Create a branch
Visual Studio
Command Line
Visual Studio 2015 & 2017
1. Open up Team Explorer and go to the Branches view.
2. Right-click the parent branch (usually master ) to base your changes and choose New Local Branch
From....
3. Supply a branch name in the required field and click Create Branch. Visual Studio automatically
performs a checkout to the newly created branch.
Delete a branch
NOTE
Deleting a branch in your local repo doesn't remove the branch on the remote.
Visual Studio
Command Line
Visual Studio 2015 & 2017
1. Open up Team Explorer and go to the Branches view.
2. Locate the branch you want to delete. Make sure that you aren't checked out to that branch, as you
can't delete the branch you are currently working in.
3. Right-click the branch name and select Delete. If you have unpublished changes, Visual Studio will
ask and make sure you want to delete the branch so you don't possibly lose work.
You can delete a remote branch using the same method - locate the tree for the remote in Team Explorer's
Branches view (such as remotes/origin ), right-click and select Delete.
You shouldn't need more than one repo on your system when you use branches to isolate your work. Set up
your development environment one time after you clone, and then use Git branches to swap between feature
work and bug fixing.
Next steps
Share code with push
Share code with push
8/26/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015
Share changes made in commits and branches using the push command. Push your branches to the remote
repository, where Git takes the commits and adds them to an existing branch on the remote or creates a new
branch with the same commits as your local branch.
Git makes sure that pushed changes are consistent with the remote branch so others can pull your commits
and merge them into their own local copy of the branch. Pushed branches that have finished work are
reviewed and merged into the main branch of the your repo through a pull request.
In this tutorial you learn how to:
Share your code with push
Video overview
https://channel9.msdn.com/series/Team-Services-Git-Tutorial/Git-Tutorial-Push/player
You can also navigate to the Synchronization view from the Changes view by choosing Sync
immediately after making a commit.
2. Select Push to share your commit with the remote repository.
If this is your first push to the repository you'll see the following message in place of the outgoing
commits list:
The current branch does not track a remote branch. Push your changes to a new branch on the origin
remote and set the upstream branch.
Select Push to push your changes to a new branch on the remote repository and set the upstream
branch. The next time you push changes you'll see the list of commits.
NOTE
To adjust your Git setup, go to Team Explorer > Settings > Repository Settings and make sure the correct
User, Email, Remotes URLs, etc. are being used.
Next steps
Review code with pull requests or update code with fetch and pull
Update code with fetch and pull
8/7/2019 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015
Update the code in your local repo with the changes from other members of your team using the following
commands:
fetch , which downloads the changes from your remote repo but does not apply them to your code.
merge , which applies changes taken from fetch to a branch on your local repo.
pull , which is a combined command that does a fetch and then a merge .
Video Overview
https://channel9.msdn.com/series/Team-Services-Git-Tutorial/Git-Tutorial-Pull/player
If there is a merge conflict between a commit you haven't pushed yet and a commit you are merging or pulling,
you'll need to resolve those conflicts before you finish updating your code.
TIP
To help keep your branches list clean and up to date, configure Git to prune remote branches during fetch. You can
configure this setting from the command line or from within Visual Studio.
Visual Studio
Command Line
Visual Studio uses the Sync view in Team Explorer to fetch changes. Changes downloaded by fetch are not
applied until you Pull or Sync the changes.
1. Open up the Synchronization view in Team Explorer by selecting the Home icon and choosing Sync.
2. Choose Fetch to update the incoming commits list. (There are two Fetch links, one near the top and one
in the Incoming Commits section. You can use either one as they both do the same thing.)
3. You can review the results of the fetch operation in the incoming commits section.
Update branches with merge
Apply changes downloaded through fetch using the merge command. Merge takes the commits retrieved
from fetch and tries to add them to your local branch. The merge will keep the commit history of your local
changes so that when you share your branch with push Git will know how others should merge your changes.
The challenge with merge is when a commit taken from fetch conflicts with an existing unpushed commit on
your branch. Git is generally very smart about resolving merge conflicts automatically, but sometimes you must
resolve merge conflicts manually and complete the merge with a new merge commit.
Visual Studio
Command Line
Team Explorer merges when you do a Pull or a Sync from the Changes view. Sync is a combined operation of
pulling remote changes and then pushing local ones, synchronizing the commits on the local and remote
branch.
1. Open up the Synchronization view in Team Explorer by selecting the Home icon and choosing Sync.
2. Choose Sync.
2. Choose Pull to fetch remote changes and merge them into your local branch. (There are two Pull links,
one near the top and one in the Incoming Commits section. You can use either one as they both do the
same thing.)
3. A confirmation message is displayed when the pull operation completes.
NOTE
This article demonstrates the merge approach. For more information on rebase and guidance on which method is
right for your scenario, see Apply changes with Rebase - When to rebase vs. merge and Rebase vs merge from the Pro Git
book.
Visual Studio
Command Line
To merge the latest changes from the master branch to your branch:
1. Open the Branches view in Team Explorer. Ensure your desired target branch is checked out, right-click
the target branch, and choose Merge From.
2. Specify the desired Merge from branch, which is master in this example, and choose Merge.)
If there are any merge conflicts you'll be notified at this stage. Resolve the merge commits before
proceeding to the next step.
3. Enter a commit message and select Commit Staged.
4. When you are ready to push your local commits, including your new merge commit, to the remote server,
choose Push from the Synchronization view.
Next steps
Share code with push
Resolve merge conflicts
Create a pull request
8/7/2019 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015
Git's workflow uses branches to isolate work until you're ready to merge the changes into your default branch,
such as master . The pull request is the collaborative process that lets the rest of the team discuss changes in a
branch and agree to merge them once everyone approves. Use pull requests to get early feedback from others
on work in progress, even if you're not ready to merge the changes into another branch.
In this image, the purple branch is merged into the blue branch through a pull request. The changes are
discussed by reviewers in the pull request before the code is merged. When you complete the pull request,
there is a merge commit (seen here as the filled blue commit) where the changes in the purple branch are now
merged in the blue branch.
In this tutorial you learn how to:
Create a pull request
Complete a pull request
From the Pull Requests view you can view pull requests opened by you, assigned to you, and you can
create new pull requests. Select New Pull Request to open up a web browser where you can create the
new pull request in the Azure DevOps Services web portal for your current branch.
3. Create the pull request. You should give a clear title for the pull request that describes the changes in the
branch. In the description field give a clear explanation of how the changes are implemented along with
any resources that might help reviewers understand the changes. You can include VSTS work items and
hyperlinks to allow others to have as much context as possible when reviewing your changes. Add any
team member who you would like to review the changes.
Complete: Complete the pull request now and merge the changes to the target branch.
Set auto-complete: If you have branch policies, you can choose Set auto-complete to configure the pull
request to close once all branch policies are met. For more information on auto-complete (and reasons why
you might not see this option), see Complete automatically.
Abandon: Choose Abandon to close the pull request without merging the changes.
Enter the message used for the merge commit and update the pull request description as needed in the dialog
that follows.
Check Complete linked work items after merging to complete any linked work items.
Check Delete <branch name> after merging to delete the source branch from the pull request. Git retains
the commit history in the master branch after the pull request is complete, so unless you plan on doing
more work in the branch, it is safe to remove.
Check Squash changes when merging to squash merge your pull request.
Check Override branch policies and enable merge to force merge even if all branch policies haven't been
satisfied. This option is only available if you have Exempt from policy enforcement permissions.
What happens when a pull request is merged?
You must resolve any merge conflicts between the pull request branch and the target branch. Git adds a new
commit (the merge commit) to the end of the master branch. This merge commit links the earlier history of
both the master branch and the commits for the branch that was merged as part of the pull request.
Next steps
Resolve merge conflicts
Apply changes with rebase
8/7/2019 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015
One of the tradeoffs from the Git feature branch workflow is that you do not actively manage your version control
history. Git creates this history as you save your code in your commits and merges changes back into the master
branch with pull requests.
This generated history can get complicated when you need to update a feature branch with changes from the
main branch to catch up on work committed by others. Your commit history will diverge from the master branch
at multiple points, making it hard to follow.
Use rebase to address the problem of updating your branch with the latest changes from the main branch.
Rebase takes the changes made in the commits in your current branch and replays them on the history of another
branch. The commit history of your current branch will be rewritten so that it starts from the most recent commit
in the target branch of the rebase. Rebasing your changes in your feature branch off the latest changes in the main
branch lets you test your changes on the most recent version in the main branch while keeping a clean Git history.
In this tutorial you learn how to:
Force push to update your remote branch
Squash local commits
Video overview
https://channel9.msdn.com/series/Team-Services-Git-Tutorial/Git-Tutorial-Rebase/player
Use caution
Rebasing is a powerful tool for catching up changes a main branch but you must be careful about its use. Some
things to keep in mind before you rebase:
1. Never rebase commits that have been pushed and shared with others. The only exception to this rule is when
you are certain no one on your team is using the commits or the branch you pushed.
2. Use rebase to catch up with the commits on another branch as you work with a local feature branch. This is
especially useful when working in long-running feature branches to check how your changes work with the
latest updates on the master branch.
3. You can't update a published branch with a push after you've rebased the local branch. You'll need to force
push the branch to rewrite the history of the remote branch to match the local history. Never force push
branches in use by others.
During a rebase, Git attempts to reconcile the changes recorded in the commits on your branch and the changes in
the commits in the target branch. Resolve any conflicts between the commits in the same way that you resolve
merge conflicts.
When to rebase vs. merge
Using rebase instead of merging branches results in an easier to follow but less exact history of commits. Your
team should agree under what circumstances you should rebase a branch. You should still always merge
branches into the main branch through a pull request. A suggested approach is to allow rebasing local changes
that you have made but haven't shared with others, but to merge once you are sharing changes with others. This
avoids trouble with rewriting history while still letting you easily catch up with changes as you develop your code
locally.
Visual Studio
Command Line
In Team Explorer, go to the Branches view. Click Rebase. You'll see a prompt to rebase the changes from your
current branch, and then a drop-down to specify which branch the changes in the current branch should be
replayed on top of. If there is a conflict, resolve it just like you resolve merge conflicts in Visual Studio.
After a successful rebase, your local branch will have a different history than your remote branch. You must force
push your local branch to update your remote branch.
A special use of rebase is available to condense the changes made in a set of commits down to one single
commit. This is useful to clean up commit histories before they are pushed to a remote branch. The benefits to the
readability are significant, and since you never rebase shared code, you can summarize the changes easily.
To consolidate commits, first decide about how many commits you'd like to squash into one. You don't have be
exact as you'll get to pick out exactly which commits to squash when you run the command. If you had five
commits to squash, then you'd make sure there are no unstaged changes and run:
You'll keep the first of the changes (leave it pick ), and then change pick to squash for the rest of the changes.
Save and close the editor. Git will now attempt to condense the commits into a single commit. After the rebase
completes, you will have a new editor window open up where Git asks you to give a commit message for the
commit with the combined changes. You'll want to condense this down to one line of text (just like you would have
for a normal commit) and save and quit the editor.
Azure DevOps Services and TFS users can squash merge their pull requests to consolidate commits added to
the master branch.
Next steps
Copy changes with cherry-pick
Copy changes with cherry-pick
8/7/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 Update 2
Copy commits from one branch to another using cherry-pick. Unlike a merge or rebase, cherry-pick only brings
the changes from the commits you select, instead of all the changes in a branch.
Cherry-pick is a great way to tackle these common problems:
Accidentally committing on the wrong branch. Cherry-pick the change(s) over to the correct branch and then
reset the original branch to the previous commit.
Pulling out a set of commits made in a feature branch so you merge them back to your master branch sooner.
Porting in specific commits from the master branch without rebasing your branch.
In this tutorial you learn how to:
Cherry-pick a commit
Cherry-pick a commit
Visual Studio
Command Line
1. Open up Team Explorer and checkout to the branch you want to cherry-pick changes into using the
Branches view.
2. Right-click the branch containing the changes you want and select View History....
3. Right-click the commit you want to cherry-pick and select Cherry-pick.
Visual Studio copies the changes made in that commit into a new one on your current branch.
Repeat this process for each commit you need to bring over to your current branch.
Next steps
Resolve merge conflicts
Resolve merge conflicts
8/29/2019 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
When you merge one branch into another, file changes from commits in one branch can conflict with the
changes the other. Git attempts to resolve these changes by using the history in your repo to determine what
the merged files should look like. When it isn't clear how to merge changes, Git halts the merge and tells you
which files conflict.
In this tutorial you learn how to:
Understand merge conflicts
Resolve merge conflicts
If you try to merge the bugfix branch into master, Git can't determine which changes to use in the merged
version. You may want to keep the changes in the master branch, the bugfix branch, or some combination of
the two. Resolve this conflict with a merge commit on the master branch that reconciles the conflicting
changes between the two branches.
The most common merge conflict situation is when you pull updates from a remote branch to your local
branch, for example from origin/bugfix into your local bugfix branch. Resolve these conflicts in the same
way - create a merge commit on your local branch reconciling the changes and complete the merge.
What does Git do to prevent merge conflicts?
Git keeps an entire history of all changes made in your repo. Git uses this history as well as the relationships
between commits to see if it can order the changes and resolve the merge automatically. Conflicts only occur
when it's not clear from your history how changes to the same lines in the same files should merge.
Preventing merge conflicts
Git is very good at automatically merging file changes in most circumstances, provided that the file contents
don't change dramatically between commits. Consider rebasing branches before you open up a pull request if
your branch is far behind your main branch. Rebased branches will merge into your main branch without
conflicts.
3. This will bring up a list of files with conflicts. Selecting a file lets you accept the changes in the source
branch you are merging from with the Take Source button or accept the changes in the branch you are
merging into using Keep Target. You can manually merge changes by selecting Merge, then entering
the changes directly into the merge tool specified in your Git settings.
4. Use the checkboxes next to the lines modified to select between remote and local changes entirely, or
edit the results directly in the Result editor under the Source and Target editor in the diff view.
5. When done making changes, click Accept Merge . Repeat this for all conflicting files.
6. Open the Changes view in Team Explorer and commit the changes to create the merge commit and
resolve the conflict.
Compare the conflicting commits as well as the differences between the common history with the
options in Visual Studio's merge tool.
Next steps
Undo changes
Undo changes
8/7/2019 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015
When undoing changes in Git, first decide what type of changes you are looking to undo. These changes fall into
three categories:
Discard uncommitted changes to a file, bringing the file back to the version in the last commit.
Reset your local branch to a previous commit.
Revert changes pushed to a remote branch and shared with others.
If you just need to make small updates such as to fix a typo or small problem introduced in your last commit,
consider amending your previous commit or fixing the change in a new commit instead of any of these other
steps.
In this tutorial you learn how to:
Discard uncommitted changes to a single file
Revert changes in shared commits
Reset a branch to a previous state
WARNING
These commands will overwrite your existing file changes. If you think you might want these changes later, consider stashing
them instead.
Visual Studio
Command Line
Visual Studio 2015 & 2017
1. Open up the Changes view in Team Explorer.
2. Under the Changes section, find the file that you want to restore to the previous version. If your change is
staged, remove it from the Staged Changes section by right-clicking and selecting Unstage.
3. Right-click that file and select Undo Changes.
Revert changes in shared commits
Use revert to undo the changes made in your commits pushed to shared branches. The revert command
creates a new commit that undoes the changes on a previous commit. No history is rewritten in a revert , making
it safe to use when working with others.
Visual Studio
Command Line
Open up the Changes view in Team Explorer. Select Actions and choose View History from the drop-down. In
the history window that appears, right-click the commit to undo and select Revert from the context menu.
Visual Studio
Command Line
1. Open up the Changes view in Team Explorer.
2. Select Actions and choose View History from the drop-down.
3. In the history window that appears, right-click the commit to reset the repo to and select Reset from the
context menu.
4. Choose Reset and delete changes....
A reset affects all files in the current branch on the repository, not just those in your current directory. Reset
only discards changes that haven't been committed yet.
Next steps
Ignore files
Ignore file changes with Git
8/7/2019 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015
Not every file created or updated in your code should be committed to Git. Temporary files from your
development environment, test outputs and logs are all examples of files that you create but are not part of your
codebase. Customize which files Git tracks through the gitignore feature.
In this tutorial you learn how to:
Use gitignore to prevent tracking of files
Ignore files only on your system
Ignore files across all repos on your system
Ignore changes to committed files
NOTE
Windows users: All file paths in the .gitignore file use a forward slash separator and not a backslash.
This is particularly useful for ignoring entire file types you don't want to ever commit, such as compiled binaries.
These steps will not delete the file from your system. They just tell Git to ignore future updates to the file.
3. Commit the removal of the file and the updated .gitignore to your repo.
Next steps
Review history
Review history
8/7/2019 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015
Git uses the parent reference information stored in each commit to manage a full history of your development.
Review this commit history to find out when file changes were made and determine differences between versions
of your code.
Git's use of feature branches and merges through pull requests mean that the commit history of your
development doesn't form a straight, chronological line. When you use history to compare versions, think in
terms of file changes between two commits instead of file changes between two points in time. A recent change
to a file in the master branch may have come from a commit created two weeks ago in a feature branch but was
only merged yesterday.
In this tutorial you learn how to:
Compare files
Retrieve files
Compare branches
Compare files
Compare the changes between two versions of a file in your Git repo.
Visual Studio
Command Line
1. Right-click the file in Solution Explorer and choose View History.... The history window will appear
showing the commit ID, author, date, and description of all changes to the file in your local repo across all
branches.
2. Find the latest commit for a branch by looking for its name on an arrow to the right of a commit.
3. View changes from the previous version of the file by right-clicking and choosing Compare with
previous.... View the changes between any two versions by selecting both commits, then right-clicking and
select Compare...
4. The diff view shows lines removed from the older commit and added in the new one.
Retrieve files
Retrieve a specific version of a file from your history, even if the file was deleted or renamed in the latest version
of your code. Retrieving an older version of the file doesn't make any changes to your current branch. Create a
new commit to bring the older version of the file into your branch.
Visual Studio
Command Line
To retrieve a previous version of a file that exists in your Visual Studio project:
1. Right-click the file in Solution Explorer and select View History. The Visual Studio History view will
appear, showing the commits in your repo that updated the file. You can filter the commits to find the exact
commit with the file version you want to restore. Double click on the version to open it in Visual Studio.
3. Right click the file to restore in the Commit Details in Team Explorer and select Open.
NOTE
The retrieved version of a file is not automatically saved to your project. To save the retrieved version to your project, select
Save As... from the File menu. If you save the file in your current project, either as a new file or overwriting an existing one,
you'll need to commit your changes to add the previous version to your local branch.
Compare branches
Review potential changes from a merge or rebase by comparing branches directly. You can compare both local
and remote branches, which is useful when checking for potential merge conflicts or to see how the changes
others have made will affect your work.
Visual Studio
Command Line
Comparing branches can be done in the web portal, which you can access from the Team Explorer Home view in
Visual Studio by choosing Web Portal.
Select Branches from the menu under Code. Locate your branch and select the ... icon to view the branch
options. Select Compare branches.
Select the branch to compare to from the drop-downs at the top. The view will display all changes between the
branches.
Understand Git history
8/29/2019 • 2 minutes to read • Edit Online
Git stores history as a graph of snapshots — called commits — of the entire repository. Each commit also contains
a pointer to one or more previous commits. Commits can have multiple parents, creating a history that looks like a
graph instead of a straight line. This difference in history is incredibly important and is the main reason users find
Git confusing.
NOTE
If you can't find a change in your Git history that you know you made, learn more about how Git history simplification works
at Git lost my changes: Taking a look at Git's history simplification.
Commit A is the parent of commit B, and commit B is the parent of commit C. This history looks very similar to a
CVCS. The arrow pointing to commit C is a branch. It's named master because that's the default name for the
mainline branch in a Git repo. Branches are pointers to specific commits, which is why branching is so lightweight
and easy in Git.
A key difference in Git compared to CVCS is that I have my own full copy of the repo. I need to keep my local
repository in sync with the remote repository by getting the latest commits from the remote repository. To do this,
I'll pull the master branch with the following command:
git pull origin master
This copies ("pulls") all commits from the master branch of the remote repo (called origin by default) to the
master branch of the local repo. The pull operation copied one new commit, and the master branch in the local
repo is now pointing to this new commit.
This is a shortcut combining two commands: git branch cool-new-feature to create the branch followed by
git checkout cool-new-feature to begin working in the branch.
Two branches now point to the same commit. I'll make a few changes on the cool-new-feature branch in two new
commits, E and F.
My commits are reachable by the cool-new-feature branch since I made them in that branch. I'm done with my
feature and want to merge it into master . To do that I'll use the following command:
The graph structure of history becomes visible when there's a merge. Git creates a new commit when I merged my
branch into another branch. This is a merge commit. There aren't any changes included in this merge commit since
I didn't have conflicts. If I had conflicts, the merge commit would include the changes needed to resolve those
conflicts.
> cd sample
> git init
> echo "some content" > test.txt
> git add test.txt
> git commit -m "Initial commit"
Now we decide to append the text "donkeys" to the file in an animal branch:
While we are experimenting, we decide maybe we want to go with fruit in our file instead, so we create a different
branch and append the text "bananas" at the end of the file instead:
> git checkout master -b fruit
> echo "bananas" >> test.txt
> git commit -am "We have added a fruit"
Feeling satisfied with our changes, we decide to merge our animal branch back into master:
commit 6b33d99b996c430a60c9552b79245d1aa8320339
Author: hross <robrodbe@microsoft.com>
Date: Mon Feb 15 10:45:33 2016 -0500
commit 206613ccd9a54b055b184c7b6c16f2ece8067e51
Author: hross <robrodbe@microsoft.com>
Date: Mon Feb 15 10:44:18 2016 -0500
Initial commit
So far so good, right? Nothing looks out of the ordinary in our log output. Now let's say we changed our minds
and decided to merge our fruit branch:
Auto-merging test.txt
CONFLICT (content): Merge conflict in test.txt
Automatic merge failed; fix conflicts and then commit the result.
Uh-oh, a merge conflict. After some consideration, we decide to use the entire test.txt file from our fruit branch.
Typically you would use some kind of text editor or merge tool, but we'll just recreate the entire file, since it's only
two lines:
Now let's take a look at the history for our test.txt file:
commit fdd4dfd816c4efebc5bdb240f49e934e299db581
Author: hross <robrodbe@microsoft.com>
Date: Mon Feb 15 10:51:06 2016 -0500
commit 206613ccd9a54b055b184c7b6c16f2ece8067e51
Author: hross <robrodbe@microsoft.com>
Date: Mon Feb 15 10:44:18 2016 -0500
Initial commit
Sure enough, we don't see any changes from our first experiment in the log, nor do we see our merge! Are they
still there? Did Git eliminate the changes entirely?
As you can see, although it simplified the log without the full-history flag, Git has kept all of our changes:
commit 5d0bb77a24e265dc154654fb3b5be331b53bf977
Merge: 6b33d99 fdd4dfd
Author: hross <robrodbe@microsoft.com>
Date: Mon Feb 15 10:59:34 2016 -0500
commit fdd4dfd816c4efebc5bdb240f49e934e299db581
Author: hross <robrodbe@microsoft.com>
Date: Mon Feb 15 10:51:06 2016 -0500
commit 6b33d99b996c430a60c9552b79245d1aa8320339
Author: hross <robrodbe@microsoft.com>
Date: Mon Feb 15 10:45:33 2016 -0500
commit 206613ccd9a54b055b184c7b6c16f2ece8067e51
Author: hross <robrodbe@microsoft.com>
Date: Mon Feb 15 10:44:18 2016 -0500
Initial commit
(c) 2016 Microsoft Corporation. All rights reserved. This document is provided "as-is." Information and views
expressed in this document, including URL and other Internet Web site references, may change without notice. You
bear the risk of using it.
This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You
may copy and use this document for your internal, reference purposes.
Adopt a Git branching strategy
8/7/2019 • 6 minutes to read • Edit Online
Distributed version control systems like Git give individuals wide flexibility in how they use version control to
share and manage code. Your team should find a balance between this flexibility and the need to collaborate and
share code in a consistent manner.
Team members publish, share, review, and iterate on code changes through Git branches shared with others.
Adopt a branching strategy for your team so that you collaborate better and spend less time managing version
control and more time developing code.
The following branching strategies are based on the way we use Git here at Microsoft. For more information, see
How we use Git at Microsoft.
Creating feature branches for all your changes makes reviewing history very simple. Look at the commits made
in the branch and look at the pull request that merged the branch.
Name your feature branches by convention
Use a consistent naming convention for your feature branches to identify the work done in the branch. You can
also include other information in the branch name, such as who created the branch.
Some suggestions for naming your feature branches:
users/username/description
users/username/workitem
bugfix/description
features/feature-name
features/feature-area/feature-name
hotfix/description
NOTE
For information on setting policies to enforce a branch naming strategy, see Require branch folders.
TIP
The build pipeline for your pull requests should be quick to complete, so it doesn't interfere with the review process.
Manage releases
Use release branches to coordinate and stabilize changes in a release of your code. This branch is long-lived and
isn't merged back into the master branch in a pull request, unlike the feature branches. Create as many release
branches as you need, but keep in mind that each active release branch represents another version of the code
you'll need to support. Lock release branches when you're ready to stop supporting a particular release.
Use release branches
Create a release branch from the master branch as you get close to your release or other milestone, such as the
end of a sprint. Give this branch a clear name associating it with the release, for example release/20 .
Create branches to fix bugs from the release branch and merge them back into the release branch in a pull
request.
This release branch workflow keeps the pillars of the basic workflow intact: feature branches, pull requests, and a
strong master branch that always has the latest version of the code.
Why not use tags for releases?
Other branching workflows use Git tags to mark a specific commits as a release. Tags are useful for marking
points in your history as important, but tags introduce extra steps in your workflow that aren't necessary if you
are using branches for your releases.
Tags are maintained and pushed separately from your commits. Team members can easily miss tagging a
commit and then have to go back through the history afterwards to fix the tag. You can also forget the extra step
to push the tag, leaving the next developer working from an older version of the code when supporting the
release.
The release branch strategy extends the basic feature branch workflow to handle releases. Your team doesn't
have to adopt any new version control process other than the cherry-pick to port changes.
Manage deployments
You can handle multiple deployments of your code in the same way you handle multiple releases. Create a clear
naming convention (such as deploy/performance-test ) and treat the environment branches like release branches.
Your team should agree on a process to update deployment branches with the code from your master branch.
Cherry-pick bugfixes in the deployment branch back to the master branch using the same steps as porting
changes from a release branch.
An exception to this recommendation is if you are using a form of continuous deployment. Use Azure Pipelines
or Build & Release in TFS when working with continuous deployment to promote builds from your master
branch to your deployment targets.
Videos
Review code with pull requests
5/31/2019 • 18 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015
Create pull requests to review and merge code in a Git project. Pull requests let your team review code and give
feedback on changes before merging it into the master branch. Pull requests can come from either topic branches
within the same repository or from a branch in a fork of the original repository. Reviewers can step through the
proposed changes, leave comments, and vote to approve or reject the code.
New to pull requests? Learn more about how to get feedback with Git pull requests.
3. Select Active to show all active pull requests for the current repository. Select Completed or
Abandoned to bring up a history of closed pull requests.
You can view all of your pull requests across different projects in your organization by choosing Pull requests in
the My Work view.
Manage to pull requests you own or are assigned to with the Pull Requests tab in the Code page on the web.
Select Active to show all active pull requests for the current repo.
Select Completed or Abandoned to bring up a history of closed pull requests.
You can view all of your pull requests in your organization, across all projects, by choosing My pull requests
from the Projects page.
Select the Create a pull request link to go to a page where you can enter your pull request details and create the
pull request.
When you publish or update a feature branch in Azure Repos, you get a prompt asking if you would like to create
a pull request in the Code view on the web. This prompt is displayed on the Pull Requests tab and the Files tab.
Select the Create a pull request link to go to a page where you can enter your pull request details and create the
pull request.
From a linked work item
Create a pull request directly from a work item linked to the branch.
1. From the Backlogs or Queries tab in the Work view , open the work item with the linked branch.
2. In the Development area of the work item, there's a link to create a pull request under the branch name.
Select the link to go to a page where you can enter your pull request details and create the pull request.
From the Pull requests page on the web
Create pull requests from any branch from the Pull Request page on the web.
Select New pull request in the upper right to go to a page where you can enter your pull request details and
create the pull request. Pick the branch you wish to have reviewed and the branch you want to merge the
changes into, such as the master branch.
From Visual Studio
Initiate pull requests directly from Visual Studio.
1. Connect to your Project from Visual Studio.
2. Open Team Explorer (select View, then Team Explorer or use the Ctrl+\ , Ctrl+M hotkey)
3. Open Pull Requests in Team Explorer by selecting the Home icon and choosing Pull Requests.
4. From the Pull Requests view you can view pull requests opened by you, assigned to you, and you can
create new pull requests. Select New Pull Request to open up a web browser where you can create the
new pull request in the Azure DevOps Services web portal.
You can also initiate pull requests from Visual Studio from the Branches view in Team Explorer by right-
clicking the branch name and selecting Create pull request while connected to your project.
If you start your pull request title with WIP, Create as draft is selected as the default option.
Publish a draft pull request
When you're ready to have the pull request reviewed and completed, you can publish it.
When a pull request is published, required reviewers are assigned and notified, policies are evaluated, and voting
is enabled.
Mark as draft
To mark an active pull request as a draft, choose Mark as draft. Marking a pull request as draft resets all votes,
and if your pull request has any votes you'll be asked to confirm.
Add detail to your pull request
Link work items and describe the changes in the branch to make it easier for others to see what problem you are
trying to solve. Change the pull request title, add a detailed description, add reviewers, link work items, and make
comments to explain your changes. When you're ready to create the pull request and have your changes
reviewed, select Create.
Don't worry if you don't have all of the work items, reviewers, or details ready when you create your pull request
- you can add them now when you create the pull request, and you can also add or update all of these items later
after you create the pull request.
Help reviewers using pull request labels
Sometimes it's important to communicate extra information about a pull request to the reviewers. Maybe the pull
request is still a work in progress, or it's a hotfix for an upcoming release - so you append some extra text in the
title, perhaps a "[WIP ]" prefix or "DO NOT MERGE". Labels now provide a way to tag pull requests with extra
information that can be used to communicate important details and help organize pull requests.
To add a label when creating a pull request, choose Add label. After a pull request is created you can manage
labels in the Labels section.
In a future release, we'll make labels even more useful by making it easier to filter pull requests using labels.
Add and remove reviewers
Add reviewers to your pull request.
1. Select the Overview tab in the pull request.
Edit the pull request description by selecting the edit link that appears when you hover over the existing
description.
Keep these fields up to date so reviewers know what the changes in the pull request are trying to accomplish.
NOTE
The size limit for files in the files view and the diff view is 5 MB. To view and diff files larger than 5 MB, you can download
the file and view it using a local diff tool on your machine.
Review previous versions of the code pushed to the source branch of the pull request from the All updates
drop-down. A new version is added to the list in the drop-down and on the Updates tab every time the branch is
updated in Azure Repos.
The diff view updates as you select different changes, showing the differences between the files in the currently
selected and previous version in the pull request. Catch up with a pull request after being away from it for awhile
by stepping through changes made since your last review.
Browse a list of changes by push from the author using the Updates tab.
You can select and view changes made in commits on the branch in the Commits tab.
Leave comments
Add comments to the pull request to make suggestions, reply to previous comments, and point out problems
with the proposed changes. Comment inline in the Files tab in your pull request by selecting the comment icon (
). Leave feedback not tied to a specific code change by commenting in the Overview tab. Reply directly to the
author or other reviewers by using @username and reference work items using #workitemID in your comments.
You can also reference other pull requests using !pullrequestID .
Update comment status to let reviewers know what you are doing to address the concerns brought up in their
review. New comments start in Active status and can be updated in the conversation using the Resolve and
Reply & resolve buttons.
Approve: Agree with the proposed changes in the pull request as-is.
Approve with suggestions: Agree with the pull request, but provide optional suggestions to improve the
code.
Wait for author: Do not approve the changes, and ask the author to review your comments. The author
should let you know when you should re-review the code after they have addressed your concerns.
Reject: The changes aren't acceptable. If you are voting this way, you should leave a comment in the pull
request detailing why the changes were rejected.
Reset feedback: Choose Reset feedback to remove your vote.
The number of required approvals in a pull request can be set from the branch policy for the branch. Pull
requests can be completed if the number of required approvals is met, even if other reviewers have rejected the
changes. Votes in a pull request can optionally be reset when new code is pushed to the branch by checking
Reset code reviewer votes when there are new changes when configuring the Require a minimum number
of reviewers branch policy.
Best practice: At least two reviewers should review and approve the changes in a significant pull request.
Complete: Complete the pull request now and merge the changes to the target branch.
Set auto-complete: If you have branch policies, you can choose Set auto-complete to configure the pull
request to close once all branch policies are met.
Abandon: Choose Abandon to close the pull request without merging the changes.
Enter the message used for the merge commit and update the pull request description as needed in the dialog
that follows.
Check Complete linked work items after merging to complete any linked work items.
Check Delete <branch name> after merging to delete the source branch from the pull request.
Check Squash changes when merging to squash merge your pull request.
Check Override branch policies and enable merge to force merge even if all branch policies haven't been
satisfied. This option is only available if you have Exempt from policy enforcement permissions.
Linked work items are also updated showing the pull request completion.
Complete automatically
Select Auto-complete from the Complete button drop-down to complete the pull request and merge the
changes as soon as all branch policies are met. Auto-completion lets you skip having to come back to the pull
request to complete it after the build finishes successfully and the reviewers approve the changes. When the
conditions are satisfied for auto-complete, the pull request is completed and you are notified via email. If there is
a conflict or an error completing the pull request, you will get an email notifying you of the issue so you can
resolve it.
Once auto-complete has been set, the pull request displays a banner confirming that the changes will be merged
as soon as the policies are satisfied. Select Cancel auto-complete to turn off auto-complete and return the pull
request to an active state. Starting with TFS 2018 Update 2, the banner displays the outstanding list of policy
criteria.
NOTE
The Auto-complete option is available in Azure Repos and TFS 2017 and higher, and is only present when you have
branch policies that must be satisfied before the pull request can be completed. If you don't see Auto-complete, it is
because you don't have any branch policies. For more information, see Branch policies.
NOTE
By default you are subscribed to several common pull request notifications. For a complete list of default notification
subscriptions, see Out-of-the-box (OOB) or default subscriptions
1. Navigate to your project and select Project settings, Notifications to view your notification settings
2. Choose New subscription to subscribe to additional notifications.
3. To edit a notification, select ... for the notification and choose View to edit the subscription.
4. To opt-out of a notification, set the State to Off.
1. Select the settings icon while you have your project open to bring up the project administration page.
2. Select the Notifications tab to view your notification settings, and choose New subscription to
subscribe to additional notifications.
3. To edit a notification, select ... for the notification and choose View to edit the subscription.
NOTE
The branch created during this revert has a single commit that reverts the file changes in the pull request. The branch does
not contain a reverted commit for each of the commits merged in the original pull request.
Configure your Git repo to use a different default branch to merge code into when your team creates new pull
requests. This is useful when you want to use a branch other than master for new changes or need to change
your main line of development in your repo.
1. Navigate to your project and select Project settings.
2. Scroll down and select Repositories from the Code section.
3. Select the desired repository and expand the branches.
4. Select the ... beside the desired branch and choose Set as default branch.
1. Select the settings icon while you have your project open to bring up the project administration page.
Azure Repos
Writing good pull request descriptions is a great way to help reviewers know what to expect when reviewing code.
They're also a great way to help track things that should be done for every change, such as testing, adding unit
tests, and updating documentation. Pull request templates can help your developers create great pull request
descriptions that meet your organization's standards.
This article shows you how to get started with pull request templates.
NOTE
Pull request templates can provide guidance, but are advisory only. Use branch policies to enforce best practices such as
requiring pull requests for key branches like master, requiring a successful build, and enforcing required reviewers. For more
information, see branch policies.
Azure Repos allows you to create the following type of pull request templates:
A default pull request template that is automatically applied for all new pull requests in the repository, unless
overridden by a branch specific pull request template
Branch specific pull request templates that are automatically applied to pull requests targeting a specific
branch
Additional pull request templates that can be optionally added by the pull request creator
The type of pull request template is determined by its filename and folder location, as covered in the following
sections. The filenames and folder locations are not case sensitive, but they must be in the default branch of your
repository.
NOTE
All pull request template files must be located in the default branch (typically master) of your repository. Only pull request
template files from the default branch are used.
You can edit or add to this description and append additional pull request templates if desired by selecting them
from the Add a template drop-down.
NOTE
When a default or branch specific pull request template is automatically applied, it replaces the standard commit messages
that are usually used for the default description. You can add them back by selecting Add commit messages.
Just like default pull request templates, multiple locations are provided to give you flexibility in where you store
branch specific pull request templates. When a pull request is created, Azure Repos searches the designated folders
in the order given for a branch specific pull request template, and uses the first one it finds that matches the branch
name. If no branch specific pull request template is found, Azure Repos then searches for a default pull request
template as described in the previous Default pull request templates section.
Select the name of the desired additional template to append its contents to the current pull request description.
NOTE
You can specify a pull request template to override any matching default or branch specific pull request by appending
?template=name.md to the querystring.
Squash merge pull requests
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017
The commit history on your master branch (or other default branch) does not follow a straight line because of
the related topic branch history. As the project grows larger, the number of topic branches worked on at the same
time increases, making the default branch history increasingly more difficult to follow.
This default branch is an accurate representation of the history of each topic branch, but it is difficult to use to
answer broader questions about your project's development.
Service hooks
Any service that wants to integrate with pull requests will need to know when a new PR has been created or
updated, so that the contents of the PR may be evaluated. Service hooks enable external systems to be alerted
when events occur in Azure DevOps Services. There are two event triggers for pull requests: - pull request
created and pull request updated. Ensure that there are subscriptions for both of these events to receive
notifications any time the code in a PR changes.
{
"state": "succeeded",
"description": "CI build succeeded",
"context": {
"name": "my-ci-system",
"genre": "continuous-integration"
},
"targetUrl": "http://contoso.com/CI/builds/1"
}
This status would be displayed to the end user in the PR Details view:
The state is shown to the user using an icon (green check for succeeded , red X for failed , a clock for
pending , and a red ! for error ).
The description is displayed next to the icon, and the context is available in a tooltip.
When a targetUrl is applied, the description will be rendered as a link to the URL.
Updating status
A service may update a PR status for a single PR by posting additional statuses, only the latest of which is shown
for each unique context . Posting multiple statuses helps users manage expectations. For example, posting a
pending status is a good way to acknowledge to the user that a system has received an event and is starting work.
Using an informative description such as the following examples can further help the user understand how the
system is working:
"Build queued"
"Build in progress"
"Build succeeded"
Iteration status
When the source branch in a PR changes, a new "iteration" is created to track the latest changes. Services that
evaluate code changes will want to post new status on each iteration of a PR. Posting status to a specific iteration
of a PR guarantees that status applies only to the code that was evaluated and none of the future updates.
Conversely, if the status posted applies to the entire PR, independent of the code, posting to the iteration may be
unnecessary. For example, checking that the author (an immutable PR property) belongs to a specific group would
only need to be evaluated once, and iteration status would not be needed.
When configuring the status policy, if iteration status is being used, the Reset conditions should be set to Reset
status whenever there are new changes. This further guarantees that the PR will not be able to be merged
until the latest iteration has a status of succeeded .
See the REST API examples for posting status on an iteration and on a pull request.
Status policy
Using status alone, details from an external service can be provided to users within the PR experience. Sometimes,
sharing information about a PR is all that is necessary, but in other cases PRs should be blocked from merging
until requirements are met. Like the in-box policies, the Status policy provides a way for external services to
block PR completion until requirements are met. If the policy is required, it must pass in order to complete the pull
request. If the policy is optional, it is informational only, and a status of succeeded is not required in order to
complete the pull request.
Status policies are configured just like other branch policies. When adding a new status policy, the name and
genre of the status policy must be entered. If the status has been posted previously you can pick it from the list; if
it is a new policy you can type in the name of the policy in the format genre/name.
When a status policy is specified, it requires that a status of succeeded with the context matching the selected
name be present to in order for this policy to pass.
An Authorized account can also be selected to require that a specific account has the authority to post status
that will approve the policy.
Policy applicability
The Policy applicability options determine whether this policy applies as soon as a pull request is created, or
whether the policy applies only after the first status is posted to the pull request.
1. Apply by default - The policy applies as soon as the pull request is created. With this option, the policy
does not pass after pull request creation until a succeeded status is posted. A PR can be marked exempt
from the policy by posting a status of notApplicable , which will remove the policy requirement.
2. Conditional - The policy doesn't apply until the first status is posted to the pull request.
Together, these options can be used to create a suite of dynamic policies. A top-level "orchestration" policy could
be set to apply by default while the PR is being evaluated for applicable policies. Then, as additional conditional
policies are determined to apply (perhaps based on specific build output), status can be posted to make them
required. This orchestration policy could be marked succeeded when it is finished evaluating or could be marked
notApplicable to indicate to the PR that the policy doesn't apply.
Custom actions
In addition to predefined service hook events that can trigger the service to update PR status, it is possible to
extend the status menu by using Azure DevOps Services extensions to give trigger actions to the end user. For
example, if status corresponds to a test run that can be restarted by the end user, it is possible to have a Restart
menu item to the status menu that would trigger tests to run. To add a status menu, you'll need to use the
contribution model. Check out the Contributions guide sample on Github where you can see the parts of code that
add the following sample items to the status menu..
Next Steps
Learn more about the PR Status API and check out the how -to guides:
Create a pull request status server with Node.js
Use Azure Functions to create custom branch policies
Configure a branch policy for an external service
Forks
8/7/2019 • 4 minutes to read • Edit Online
What's in a fork
A fork starts with all the contents of its upstream (original) repository. When you create a fork, you can choose
whether to include all branches or limit to only the default branch. None of the permissions, policies, or build
pipelines are applied. The new fork acts as if someone cloned the original repository, then pushed to a new, empty
repository. After a fork has been created, new files, folders, and branches are not shared between the repositories
unless a PR carries them along.
Sharing code between forks
You can create PRs in either direction: from fork to upstream, or upstream to fork. The most common direction
will be from fork to upstream. The destination repository's permissions, policies, builds, and work items will apply
to the PR.
For convenience, after cloning you'll want to add the upstream repository (where you forked from) as a remote
named upstream .
Visual Studio
Command Line
To add your upstream repository in Visual Studio, follow these steps:
1. Open the Settings page.
2. Choose Repository Settings.
4. Add a new remote called upstream , using the Git clone URL of the repo you forked.
5. Select Save and the new remote is added and displayed in the repository settings.
3. Open the Branches page in Team Explorer. Make sure master is checked out.
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 Update 3
Choose a method to securely login and access the code in your Azure Repos/TFS Git repo. Use these credentials
with Git on the command line or from any Git client that supports HTTPS or SSH authentication. Limit the scope
of access and revoke these credentials from the web when they are no longer needed.
Using Visual Studio? Team Explorer handles authentication with Azure Repos for you.
Authentication comparison
ADDITIONAL TOOLING
AUTHENTICATION TYPE WHEN TO USE SECURE? EASE OF SETUP REQUIRED
Personal access When you need an Very secure (when Easy Optional (Git
tokens easy to configure using HTTPS) credential managers)
credential or need
configurable access
controls
SSH When you already Very secure Intermediate Windows users will
have SSH keys set up, need the SSH tools
or are on macOS or included with Git for
Linux Windows
SSH is a great option if you've already got it set up on your system—just add a public key to Azure DevOps
Services and clone your repos using SSH. If you don't have SSH set up on your computer, you should use personal
access tokens and HTTPS instead-it's secure and easier to set up.
Learn more about setting up SSH with Azure DevOps Services
Alternate credentials
IMPORTANT
Use of alternate credentials is not recommended.
Alternate credentials are not supported on TFS.
The username specified for the alternate credentials must be unique within that user's Azure DevOps organization, and
can't be reused more than once per organization.
Create an alternate user name and password to access your Git repository using alternate credentials. Unlike
personal access tokens, this login doesn't expire and can't be scoped to limit access to your Azure DevOps Services
data. Use alternate credentials as a last resort when you can't use personal access tokens or SSH keys.
How dates work in Git
5/10/2019 • 2 minutes to read • Edit Online
Git tracks two dates in commits: author date and commit date. In addition, Azure DevOps Services and TFS track
when a commit was first pushed to the server.
Author date: when a commit was originally authored. Typically, when someone first ran git commit .
Commit date: when a commit was applied to the branch. In many cases it is the same as the author date.
Sometimes it differs: if a commit was amended, rebased, or applied by someone other than the author as part of
a patch. In those cases, the date will be when the rebase happened or the patch was applied.
Push date: when a commit was pushed to the remote repository in question. This date is specific to the remote
version control system you are using, and won't be available in your local repository.
When you run git log , by default you will see the author date. If you want to see commit date, you can use one of
the many command line options, such as --pretty=fuller .
Let's look at a brief example to see these concepts in practice. First we will create a normal commit:
git init
echo test > file.txt
git add *
git commit -m "A normal commit message"
If we look at our regular log history we would see something like the following:
git log
commit 17232459f0ae25adeff21c9e21742ba22b7f3499
Author: Ross Brodbeck <robrodbe@microsoft.com>
Date: Thu Feb 25 19:38:54 2016 -0500
An amended commit
Now let's view the same commit with the author date:
commit 17232459f0ae25adeff21c9e21742ba22b7f3499
Author: Ross Brodbeck <robrodbe@microsoft.com>
AuthorDate: Thu Feb 25 19:38:54 2016 -0500
Commit: Ross Brodbeck <robrodbe@microsoft.com>
CommitDate: Thu Feb 25 19:39:36 2016 -0500
An amended commit
Note the (slight) difference between the author date and commit date above. The author date is my original,
unedited, commit time. The commit date is the time at which I ran the --amend command.
In fact, there are a lot of git log options to help you understand dates better. For example, passing the --date
flag will allow you to determine how dates are displayed. This can be useful for normalizing time zones (git displays
dates in their original time zone, by default) or changing the date display string.
To learn more about the various formatting options, see the git log man page.
When you commit to your local repo, Git includes your name and email address as part of the commit. This can
sometimes lead to confusion. The name and email on your commits may not match the identity you log in with on
a Git host like Azure Repos. Further, you may have commits under several different names and email addresses
even though you were the author for each of them.
Where does Azure DevOps Services get your name and email?
Your details in Azure DevOps Services come from your profile. Your profile was originally populated from details in
your Microsoft Account or Azure Active Directory account, but you may change these details yourself. When you
edit a file in the web or complete a PR, Azure Repos supplies your profile details as the author of the commit. This
is another opportunity for your name or email address to be specified differently.
In Azure DevOps Services, you can update your profile by clicking your picture in the upper right corner and
choosing My profile.
In most other cases, it's best to keep the existing author information. To change an author name or email, you must
create a new commit. When you change a commit, all subsequent commits descended from that commit also must
change.
Git Cross-Platform Compatibility
5/31/2019 • 4 minutes to read • Edit Online
Azure Repos
Azure Repos | Azure DevOps Server 2019 | TFS 2018
The Windows, macOS, and Linux file systems each have limitations and behaviors that are not always supported
by one or more of the other platforms. Since Git is a cross-platform technology, it is possible for a developer on
one platform to make a commit containing files or folders that have incompatible names with another platform's
file system. Protecting your repo from this is important because developers on other platforms may unknowingly
checkout a commit that corrupts their working direction due to unsupported file or paths names.
Azure Repos offers three cross-platform compatibility settings that help protect your repo from people pushing
commits that are incompatible with one or more platforms. The three file system limitations these settings are
related to are:
Case Sensitivity
Restricted File and Folder Names
Path Length Restrictions
Case Sensitivity
The Windows and macOS file systems are case-insensitive (but case-preserving) by default. Most Linux
filesystems are case-sensitive. Git was built originally to be the Linux kernel's version control system, so
unsurprisingly, it's case-sensitive.
While many of the issues with a case-insensitive OS have been addressed in Git for Windows, a few quirks
remain.
File and folder names
On Linux, checking out a Git repo which contains both "File.txt" and "file.txt" is no problem. Those are distinct
filenames. On Windows and macOS, checking out both files will result in the second one overwriting the first one.
If two folders differ only by case, their contents will end up mixed together on case-insensitive filesystems.
Fixing case conflicts
One way to fix a repository with this problem is to check it out in a case-sensitive environment. Rename files and
folders so they no longer conflict, then push those changes to the repository. Windows Subsystem for Linux is one
such environment. Another approach is to use the command git mv -f <conflicting name> <non-conflicting name>
for each conflict, being careful to use exact capitalization on both file names.
Avoiding case conflicts
It's good to avoid creating this situation in the first place. Azure Repos offers a case-enforcement setting to
prevent pushes which would lead to this situation. For developers, adopting the habit of using tab-completion to
commit files will also help. Since both Windows and macOS are case-preserving, this will ensure that Git's
internals see the exact same casing that the filesystem uses.
Branch and tag names
You can create two branches or tags (known as 'refs') that differ only in casing. Git's internals, as well as Azure
DevOps Services/TFS, will treat them as two separate refs. On a user's machine, Git uses the filesystem to store
refs. Fetches and other operations begin to fail because of the ambiguity. Each ref is represented by a small file,
and if a ref name contains / characters, the parts before the final / are represented by folders.
One simple way to avoid issues is to always use all-lowercase branch and tag names. If you have already created
two branches or tags with this problem, you can fix it in the Azure Repos web UI.
Fixing branch names
From the branches page, navigate to the related commit. In the context menu, choose "New branch". Give the
branch a new name that doesn't have a case conflict. Return to the branches page and delete the conflicting
branch.
Fixing tag names
The steps for fixing a tag name are similar to branches. From the tags page, navigate to the tagged commit. In the
context menu, choose "Create tag". Give the tag a new name that doesn't have a case conflict. Return to the tags
page and delete the conflicting tag.
File Name Restrictions Reserved File Names: CON, Filenames ending in / Filenames ending in /
PRN, AUX, NUL, COM1 -
COM9, LPT1 - LPT9
Reserved Characters:
\ / : * ? " < >
Filenames ending in . or
whitespace
Path Length Restrictions Paths in Windows have a File names are limited to File names are limited to 255
maximum length of 260 255 characters characters
characters (incl. a null
terminator). Path max in HFS+ are Path max is 4096
documented as unlimited,
For directories with .NET the though some macOS
fully qualified file name must versions cap it at 1016
be less than 260 characters, characters. Some file
and the directory name systems support 1016 as
must be less than 248 max path
characters.
Git preferences and settings in Visual Studio
8/7/2019 • 7 minutes to read • Edit Online
2. Choose Global Settings or Repository Settings to view and configure global-level or repository-level
settings.
3. Visual Studio allows you to configure several common Git settings, as described in the following sections of
this article. After configuring your desired settings, select Update to save the updated settings.
Git settings
Visual Studio allows you to configure and check some of the most common Git configuration settings. The
settings in this section can be viewed and modified in Visual Studio, but are managed by Git configuration files.
Name and email
Prune remote branches during fetch
Rebase local branch when pulling
Cryptographic network provider
Ignore & attributes files
Diff & merge Tools
Remotes
Other
NOTE
Git settings configured in Visual Studio's Global Settings correspond to settings in Git's user-specific configuration file, and
the settings in Repository Settings correspond to settings in the repository-specific configuration file. For more information
about Git configuration, see the Pro Git chapter on customizing Git, the git-config documentation, and the Pro Git reference
on configuration files. To configure Git settings not exposed in Visual Studio, use the git config command to write a value
to your configuration files: git config [--local|--global|--system] section.key value .
Note that for Repository Settings, you'll first need to check Override global user name and email
settings.
We recommend setting this option to True at the global level. Valid settings are:
True (recommended)
False
Unset (default)
Visual Studio
Command Line
Requires Visual Studio 2017 Update 5 and later.
1. In Team Explorer, go to Settings. Go to Global Settings and set Prune remote branches during fetch
to True (recommended). Select Update to save.
Note that it is not possible to configure pull.rebase to Interactive in Visual Studio. Visual Studio does not have
interactive rebase support. To configure pull.rebase to use interactive mode, use the command line.
Cryptographic network provider
Cryptographic network provider is a Git configuration setting at global scope that configures which SSL backend
to use at runtime, and corresponds to the git config http.sslBackend setting. The values are:
OpenSSL: Use OpenSSL for TLS and SSL protocols.
Secure Channel: Use Secure Channel (schannel) for TLS and SSL protocols. Schannel is the native Windows
solution, accessing the Windows Credential Store, thereby allowing for enterprise-wide management of
certificates.
Unset (default): If this setting is unset, OpenSSL is the default.
Visual Studio
Command Line
Requires Visual Studio 2017 Update 7 and later.
1. In Team Explorer, go to Settings. Go to Global Settings to configure this setting.
2. Set Cryptographic network provider to the desired value, and select Update to save.
Remotes
The Remotes section allows you to configure the remotes for this repository. This setting corresponds to the git
remote command and is available at the repository scope.
Other
The Other section allows you to view the Git configuration settings for this repository, with the exception of
settings that are displayed and managed in the Visual Studio Git settings pane.
To view all of your Git configuration settings, you can open and view the configuration files themselves, or you can
run git config --list to display the settings.
When checked, git merge commands issued by Visual Studio are run with the --commit option.
When unchecked, git merge commands issued by Visual Studio are run with the --no-commit --no-ff options.
For more information on these options, see --commit and --no-commit and --no-ff.
Enable push --force
Requires Visual Studio 2017 and later.
When enabled, this setting allows you to push --force from within Visual Studio. By default Enable push --force
is disabled.
WARNING
Use push --force with caution as it can overwrite changes that have been pushed to the branch since your last pull. For
more information, see push --force.
Repository settings
5/31/2019 • 4 minutes to read • Edit Online
Azure Repos
Azure Repos | Azure DevOps Server 2019 | TFS 2018 Update 2
Git repositories can be customized to a great extent on Azure DevOps Services and Team Foundation Server.
Global options for entire repositories are configured by repository settings. There are also user-specific and
branch-specific controls, covered by permissions and branch policies respectively.
This topic covers server-side repository settings. You may also want to learn about client-side Git preferences.
Case enforcement
Git is case-sensitive, meaning that a file called "Foo.txt" is different from a file called "foo.txt". Windows and
macOS default to case-insensitive file systems, meaning that "Foo.txt" and "foo.txt" are the same name. This can
cause problems for users if someone on a case-insensitive system pushes files, folders, branches, or tags that only
differ by letter case.
If most of your users are on Windows or macOS, we recommend turning on this setting. It will block the
introduction of new files, folders, branches, or tags that would cause such a conflict. The user will have to rewrite
their unpushed history to fix the problem, then try the push again.
This setting will not fix a repository which already contains objects that only differ by case. We recommend fixing
such issues before turning the policy on. You can rename files and folders or re-create branches and tags using
new, non-conflicting names.
Restrict File Names
Not all files names are allowed on the three major OS file systems (Windows, macOS, and Linux). Developers can
push commits to a shared repository that may contain files or folders with names that are invalid on one or more
platforms. If these files or folders are fetched and checked out on a platform where they are invalid then the
working directory can become corrupted.
This setting will block pushes to your repository that contain files or folders names that are invalid on any
platform. See what names are invalid
Restrict Path length
Not all path lengths are allowed on the three major OS file systems (Windows, macOS, and Linux). Developers
can push commits to a shared repository that may contain files or directories with path lengths that are invalid on
one or more platforms. If these files or directories are fetched and checked out on a platform where they are
invalid then the working directory can become corrupted.
This setting will block pushes to your repository that contain files or directories with path names that are invalid
on any platform. See what path lengths are invalid. When enabled, a default value of 248 is selected because
that is the highest max length that is 100% supported across all three major platforms.
The max path value can be modified. For example, if you only have macOS or Linux developers in your
organization, then you may optionally choose to set it to highest value that is 100% supported on both platforms (
1016 ). You may also optionally choose to set a lower max path value if you wish to enforce certain directory &
naming conventions for your organization.
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015
Git is great at keeping the footprint of your source code small because the differences between versions are easily
picked out and code is easily compressed. Large files that don't compress well and change entirely between
versions (such as binaries) present problems when stored in your Git repos. Git's fast performance comes from its
ability to address and switch to all versions of a file from its local storage.
If you have large, undiffable files in your repo such as binaries, you will keep a full copy of that file in your repo
every time you commit a change to the file. If many versions of these files exist in your repo, they will dramatically
increase the time to checkout, branch, fetch, and clone your code.
IMPORTANT
Even small binaries can cause problems if updated often. One hundred changes to a 100KB binary file uses up as much
storage as 10 changes to a 1MB binary, and due to the frequency of updates to the smaller binary will take slow down
branching performance more often than the large binary.
version https://git-lfs.github.com/spec/v1
oid a747cfbbef63fc0a3f5ffca332ae486ee7bf77c1d1b9b2de02e261ef97d085fe
size 4923023
NOTE
The GitHub URL included for the version value only defines the LFS pointer file type, and is not a link to your binary file.
Known issues
If you use a version of LFS below 2.4.0 with TFS, there's an extra setup step required to authenticate using NTLM
instead of Kerberos. This step is no longer necessary as of LFS 2.4.0, and we highly recommend you upgrade.
Use SSH key authentication
8/29/2019 • 12 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 Update 3
Connect to your Git repos through SSH on macOS or Linux, or on Windows when you can't (or don't want to)
use the recommended Git Credential Managers or Personal Access Tokens to securely connect using HTTPS
authentication.
IMPORTANT
SSH URLs have changed, but old SSH URLs will continue to work. If you have already set up SSH, you should update your
remote URLs to the new format:
Verify which remotes are using SSH by running git remote -v in your Git client.
Visit your repository on the web and select the Clone button in the upper right.
Select SSH and copy the new SSH URL.
In your Git client, run: git remote set-url <remote name, e.g. origin> <new SSH URL> . Alternatively, in Visual
Studio, go to Repository Settings, and edit your remotes.
NOTE
As of Visual Studio 2017, SSH can be used to connect to Git repos.
Linux
macOS running at least Leopard (10.5)
Windows systems running Git for Windows
Configure SSH using the command line. bash is the common shell on Linux and macOS and the Git for
Windows installation adds a shortcut to Git Bash in the Start menu. Other shell environments will work, but are
not covered in this article.
Step 1: Create your SSH keys
NOTE
If you have already created SSH keys on your system, skip this step and go to configuring SSH keys.
The commands here will let you create new default SSH keys, overwriting existing default keys. Before
continuing, check your ~/.ssh folder (for example, /home/jamal/.ssh or C:\Users\jamal\.ssh) and look for the
following files:
id_rsa
id_rsa.pub
If these files exist, then you have already created SSH keys. You can overwrite the keys with the following
commands, or skip this step and go to configuring SSH keys to reuse these keys.
Create your SSH keys with the ssh-keygen command from the bash prompt. This will create a 2048-bit RSA
key for use with SSH. You can give a passphrase for your private key when prompted—this provides another
layer of security for your private key. If you give a passphrase be sure to configure the SSH agent to cache your
passphrase so you don't have to enter it every time you connect.
$ ssh-keygen -C "jamal@fabrikam.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/jamal/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/jamal/.ssh/id_rsa.
Your public key has been saved in /c/Users/jamal/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:******************************************* jamal@fabrikam.com
The key's randomart image is:
+---[RSA 2048]----+
|+. +yX*o . |
|... ..E+*=o |
| ..o.=E=.o |
| . * =.o . |
| . S o o.. |
| + .oo |
| S+. . |
| ..+.+ |
| o*.. |
+----[SHA256]-----+
This produces the two keys needed for SSH authentication: your private key ( id_rsa ) and the public key (
id_rsa.pub ). It is important to never share the contents of your private key. If the private key is compromised,
attackers can use it to trick servers into thinking the connection is coming from you.
Step 2: Add the public key to Azure DevOps Services/TFS
Associate the public key generated in the previous step with your user ID.
1. Open your security settings by browsing to the web portal and selecting your avatar in the upper right of
the user interface. Select Security in the menu that appears.
2. Select SSH Public Keys , then select Add.
3. Copy the contents of the public key (for example, id_rsa.pub) that you generated into the Key Data field.
IMPORTANT
Avoid adding whitespace or new lines into the Key Data field, as they can cause Azure DevOps Services to use an
invalid public key. When pasting in the key, a newline often is added at the end. Be sure to remove this newline if it
occurs.
4. Give the key a useful description (this will be displayed on the SSH public keys page for your profile) so
that you can remember it later. Select Save to store the public key. Once saved, you cannot change the key.
You can delete the key or create a new entry for another key. There are no restrictions on how many keys
you can add to your user profile.
Step 3: Clone the Git repository with SSH
NOTE
To connect with SSH from an existing cloned repo, see updating your remotes to SSH.
1. Copy the SSH clone URL from the web portal. In this example the SSL clone URL is for a repo in an
organization named fabrikam -fiber, as indicated by the first part of the URL after dev.azure.com .
NOTE
Project URLs have changed with the release of Azure DevOps Services and now have the format
dev.azure.com/{your organization}/{your project} , but you can still use the existing visualstudio.com
format. For more information, see VSTS is now Azure DevOps Services.
SSH may display the server's SSH fingerprint and ask you to verify it.
For cloud-hosted Azure DevOps Services, where clone URLs contain either ssh.dev.azure.com or
vs-ssh.visualstudio.com , the fingerprint should match one of the following:
When you are asked if you want to continue connecting, type yes . Git will clone the repo and set up the origin
remote to connect with SSH for future Git commands.
TIP
Avoid trouble: Windows users will need to run a command to have Git reuse their SSH key passphrase.
start-ssh-agent.cmd
If you are using the Bash shell (including Git Bash), start ssh-agent with:
eval `ssh-agent`
I use PuTTY as my SSH client and generated my keys with PuTTYgen. Can I use these keys with Azure DevOps
Services?
Yes. Load the private key with PuTTYgen, go to Conversions menu and select Export OpenSSH key. Save the
private key file and then follow the steps to set up non-default keys. Copy your public key directly from the
PuTTYgen window and paste into the Key Data field in your security settings.
How can I verify that the public key I uploaded is the same key as I have locally?
You can verify the fingerprint of the public key uploaded with the one displayed in your profile through the
following ssh-keygen command run against your public key using the bash command line. You will need to
change the path and the public key filename if you are not using the defaults.
You can then compare the MD5 signature to the one in your profile. This is useful if you have connection
problems or have concerns about incorrectly pasting in the public key into the Key Data field when adding the
key to Azure DevOps Services.
How can I start using SSH in a repository where I am currently using HTTPS?
You'll need to update the origin remote in Git to change over from a HTTPS to SSH URL. Once you have the
SSH clone URL, run the following command:
You can now run any Git command that connects to origin .
I'm using Git LFS with Azure DevOps Services and I get errors when pulling files tracked by Git LFS.
Azure DevOps Services currently doesn't support LFS over SSH. Use HTTPS to connect to repos with Git LFS
tracked files.
How can I use a non default key location, i.e. not ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub?
To use keys created with ssh-keygen in a different place than the default, you do two things:
1. The keys must be in a folder that only you can read or edit. If the folder has wider permissions, SSH will not
use the keys.
2. You must let SSH know the location of the keys. You make SSH aware of keys through the ssh-add
command, providing the full path to the private key.
ssh-add /home/jamal/.ssh/id_jamal.rsa
On Windows, before running ssh-add , you will need to run the following command from included in Git for
Windows:
start-ssh-agent.cmd
This command runs in both Powershell and the Command Prompt. If you are using Git Bash, the command you
need to use is:
eval `ssh-agent`
You can find ssh-add as part of the Git for Windows distribution and also run it in any shell environment on
Windows.
On macOS and Linux you also must have ssh-agent running before running ssh-add , but the command
environment on these platforms usually takes care of starting ssh-agent for you.
I have multiple SSH keys. How do I use different SSH keys for different SSH servers or repos?
Generally, if you configure multiple keys for an SSH client and connect to an SSH server, the client can try the
keys one at a time until the server accepts one.
However, this doesn't work with Azure DevOps for technical reasons related to the SSH protocol and how our
Git SSH URLs are structured. Azure DevOps will blindly accept the first key that the client provides during
authentication. If that key is invalid for the requested repo, the request will fail with the following error:
For Azure DevOps, you'll need to configure SSH to explicitly use a specific key file. One way to do this to edit
your ~/.ssh/config file (for example, /home/jamal/.ssh or C:\Users\jamal\.ssh ) as follows:
# The settings in each Host section are applied to any Git SSH remote URL with a matching hostname.
# Generally:
# * SSH uses the first matching line for each parameter name, e.g. if there's multiple values for a
# parameter across multiple matching Host sections
# * "IdentitiesOnly yes" prevents keys cached in ssh-agent from being tried before the IdentityFile
# values we explicitly set.
# * On Windows, ~/.ssh/your_public_key maps to %USERPROFILE%\.ssh\your_public_key, e.g.
# C:\Users\<username>\.ssh\your_public_key.
# To use the same key across all hosted Azure DevOps organizations, where the SSH URL host is
# ssh.dev.azure.com (like git@ssh.dev.azure.com:v3/some_organization/some_project/some_repo), add
# the Host section below:
Host ssh.dev.azure.com
IdentityFile ~/.ssh/your_public_key
IdentitiesOnly yes
# Since all hosted Azure DevOps URLs have the same hostname (ssh.dev.azure.com), if you need
# different keys for different organizations (or just different repos within the same organization),
# you'll need to use host aliases to create separate Host sections.
#
# Imagine that we have the following two SSH URLs:
# * git@ssh.dev.azure.com:v3/org1/org1_project/org1_repo
# * For this, we want to use key1, so we'll use devops_key1 as the Host alias.
# * git@ssh.dev.azure.com:v3/org2/org2_project/org2_repo
# * For this, we want to use key2, so we'll use devops_key2 as the Host alias.
#
# You'll need to substitute ssh.dev.azure.com with the Host alias in the SSH URL you use with Git.
# The SSH URLs above become:
# * git@devops_key1:v3/org1/org1_project/org1_repo
# * git@devops_key2:v3/org2/org2_project/org2_repo
#
# To set explicit keys for the two host aliases and to tell SSH to use the correct actual hostname,
# add the next two Host sections:
Host devops_key1
HostName ssh.dev.azure.com
IdentityFile ~/.ssh/public_key_for_org1
IdentitiesOnly yes
Host devops_key2
HostName ssh.dev.azure.com
IdentityFile ~/.ssh/public_key_for_org2
IdentitiesOnly yes
# If you have an SSH URL where the hostname is vs-ssh.visualstudio.com, from when Azure DevOps was
# formerly called Visual Studio Team Services, add the following Host section.
# Alternately, you can just replace the hostname in your SSH URL with ssh.dev.azure.com. Both
# ssh.dev.azure.com and vs-ssh.visualstudio.com point to the same place.
Host vs-ssh.visualstudio.com
IdentityFile ~/.ssh/your_public_key
IdentitiesOnly yes
# If you have an on-premises Azure DevOps Server instance, where SSH URLs look like
# ssh://someHost:22/someCollection/some_project/_git/some_repo, add the following Host section:
Host someHost
IdentityFile ~/.ssh/your_public_key
IdentitiesOnly yes
# Put global defaults here. Note that "*" also matches any hosts that match the sections above, and
# remember that SSH uses the first matching line for each parameter name.
Host *
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015
Git Credential Managers simplify authentication with your Azure DevOps Services/TFS Git repos. Credential
Managers let you use the same credentials that you use for the Azure DevOps Services/TFS web portal and
support multi-factor authentication through Microsoft Account (MSA) or Azure Active Directory (Azure AD ). In
addition to supporting multi-factor authentication with Azure DevOps Services, the credential managers also
provide support two-factor authentication with GitHub repositories.
Azure DevOps Services provides IDE support for MSA and Azure AD authentication through Team Explorer in
Visual Studio, IntelliJ and Android Studio with the Azure Repos Plugin for IntelliJ, and Eclipse (with the Team
Explorer Everywhere plug-in). If your environment doesn't have an integration available, configure your IDE with
a Personal Access Token or SSH to connect with your to your repos.
Review the system and software requirements before installing the credential manager.
On macOS and Linux, there are several install options that use native package managers to install the credential
manager. After installing the package for your platform, run the following command to configure Git to use the
credential manager :
Once authenticated, the credential manager creates and caches a personal access token for future connections to
the repo. Git commands that connect to this account won't prompt for user credentials until the token expires or
is revoked through Azure DevOps Services/TFS.
Getting help
You can open up and report issues with the Git Credential Manager for Windows on the project GitHub.
Frequently Asked Questions for the Git Credential Manager for Windows are available in the online readme.
Manual installation steps for the Windows Git Credential Manager and the macOS and Linux Git Credential
Manager are available. Use these steps to install the credential manager if the recommended steps above are not
suitable for your environment.
Learn more
In addition to providing full source code, we've also documented how the credential manager integrates with Git.
Refer to the MSDN blog posts on the macOS and Linux Git Credential Manager and the Windows Credential
Manager. There is also an article on the project GitHub with information on the low -level internals of the Git
Credential Manager for Windows.
Create a pull request status server with Node.js
8/7/2019 • 8 minutes to read • Edit Online
Prerequisites
An organization in Azure DevOps with a Git repo. If you don't have an organization, sign up to upload and
share code in free unlimited private Git repositories.
Install VS Code or other code editor of your choice. The instructions in this guide use VS Code but the steps in
other code editors are similar.
Install Node.js
To install Node.js, download the LTS release appropriate for your platform. The download contains an installer,
which you can run to install the Node.js runtime on your local machine. When installing Node.js, be sure to keep
the npm package manager portion of the install, which is selected by default.
mkdir pr-server
cd pr-server
2. Use the npm init command to create a new package.json file for the project.
npm init
Press Enter to accept the defaults for all of the options except the entry point. Change it to app.js
3. Install Express in the pr-server directory using the following command. This installs Express and saves it to
the dependencies list.
4. Create a simple Express app to build upon for the PR status server. The following steps are based on the
Express Hello world example. Open the project folder in VS Code by running the following command from
the pr-server folder.
code .
5. Create a new file (Ctrl + N) and paste in the following sample code.
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
})
node app.js
node app.js
Ngrok will create a public URL that forwards to localhost:3000 . Note that URL as you will need it in the
next step. It will look something like this:
http://c3c1bffa.ngrok.io
3. Browse to your project in Azure DevOps, e.g. https://dev.azure.com/<your account>/<your project name>
4. From the navigation menu, hover over the gear and select Service Hooks.
If you already have other service hooks configured, select the green plus (+) to create a new service hook
subscription.
6. On the New Service Hooks Subscription dialog, select Web Hooks from the list of services, then select
Next.
7. Select Pull request created from the list of event triggers, then select Next.
8. In the Action page, enter the URL from ngrok in the URL box. Select Test to send a test event to your
server.
In the ngrok console window, you'll see an incoming POST that returned a 200 OK , indicating your server
received the service hook event.
HTTP Requests
-------------
POST / 200 OK
In the Test Notification window, select the Response tab to see the details of the response from your server.
You should see a content length of 17 that matches the length of the string from your POST handler (i.e.
"Received the POST").
9. Close the Test Notification window, and select Finish to create the service hook.
Go through steps 3-9 again but this time configure the Pull request updated event.
IMPORTANT
Be sure to go through the preceding steps twice and create service hooks for both the Pull request created and Pull
request updated events.
app.use(bodyParser.json());
3. To simplify making REST API calls to Azure Repos, install the azure-devops-node-api package.
4. Update app.js to use the azure-devops-node-api package, set up the details for a connection to your
account, and get an instance of the Git API.
5. Create an environment variable for your collection URL, replacing <your account> with the name of your
Azure DevOps organization.
6. Create a personal auth token (PAT) for your app to use, following these instructions: Authenticating with
personal access tokens. You should create a new PAT for every service that you use to access your account,
naming it appropriately.
7. Create an environment variable for your PAT.
8. Update the post() function to read the PR details from the service hook payload. You'll need these values
in order to post back status.
var prStatus = {
"state": "succeeded",
"description": "Ready for review",
"targetUrl": "http://visualstudio.microsoft.com",
"context": {
"name": "wip-checker",
"genre": "continuous-integration"
}
}
10. Instead of just blindly posting the succeeded status, inspect the PR title to see if the user has indicated if the
PR is a work in progress by adding WIP to the title. If so, change the status posted back to the PR.
if (title.includes("WIP")) {
prStatus.state = "pending";
prStatus.description = "Work in progress"
}
11. Finally, post the status using the createPullRequestStatus() method. It requires the status object, the repo
ID, and the pull request ID. Output the response to the node console so you can see the result of the post.
// Get the details about the PR from the service hook payload
var repoId = req.body.resource.repository.id;
var pullRequestId = req.body.resource.pullRequestId;
var title = req.body.resource.title;
node app.js
5. Add WIP in the title to test the functionality of the app. Select Create to create the PR.
6. Once the PR has been created, you will see the status section, with the Work in progress entry which links
to the URL specified in the payload.
7. Update the PR title and remove the WIP text and note that the status changes from Work in progress to
Ready for review.
Next Steps
In this article, you learned the basics of how to create a service that listens for PR events via service hooks and
can post status messages using the status API. For more information about the pull request status API see the
REST API documentation.
Configure a branch policy for an external service.
Use Azure Functions to create custom branch policies
8/7/2019 • 6 minutes to read • Edit Online
Prerequisites
An organization in Azure DevOps with a Git repo. If you don't have an organization, sign up to upload and share
code in free unlimited private Git repositories.
// Get the pull request object from the service hooks payload
dynamic jObject = JsonConvert.DeserializeObject(data.ToString());
log.Info("Service Hook Received for PR: " + pullRequestId + " " + pullRequestTitle);
return req.CreateResponse(HttpStatusCode.OK);
}
catch (Exception ex)
{
log.Info(ex.ToString());
return req.CreateResponse(HttpStatusCode.InternalServerError);
}
}
3. From the navigation menu, hover over the gear and select Service Hooks.
5. On the New Service Hooks Subscription dialog, select Web Hooks from the list of services, then select
Next.
6. Select Pull request created from the list of event triggers, then select Next.
7. In the Action page, enter the URL that you copied in step 1 in the URL box. Select Test to send a test event
to your server.
In the Azure function log window, you'll see an incoming POST that returned a 200 OK , indicating your
function received the service hook event.
HTTP Requests
-------------
POST / 200 OK
In the Test Notification window, select the Response tab to see the details of the response from your server.
You should see the response from your server.
8. Close the Test Notification window, and select Finish to create the service hook.
Go through steps 2-8 again but this time configure the Pull request updated event.
IMPORTANT
Be sure to go through the preceding steps twice and create service hooks for both the Pull request created and Pull
request updated events.
IMPORTANT
This sample code stores the PAT in code to simplify the sample. It is recommended to store secrets in KeyVault and retrieve
them from there.
This sample inspects the PR title to see if the user has indicated if the PR is a work in progress by adding WIP to
the title. If so, the sample code changes the status posted back to the PR. Replace the code in your Azure function
with the following code to implement updating the status posted back to the PR.
using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using Newtonsoft.Json;
/*
This is here just to simplify the sample, it is recommended to store
secrets in KeyVault and retrieve them from there.
*/
private static string pat = "[PAT TOKEN]";
// Get the pull request object from the service hooks payload
dynamic jObject = JsonConvert.DeserializeObject(data.ToString());
log.Info("Service Hook Received for PR: " + pullRequestId + " " + pullRequestTitle);
PostStatusOnPullRequest(pullRequestId, ComputeStatus(pullRequestTitle));
return req.CreateResponse(HttpStatusCode.OK);
}
catch (Exception ex)
{
log.Info(ex.ToString());
return req.CreateResponse(HttpStatusCode.InternalServerError);
}
}
if (pullRequestTitle.ToLower().Contains("wip"))
{
state = "pending";
description = "Work in progress";
}
return JsonConvert.SerializeObject(
new
{
State = state,
Description = description,
TargetUrl = "http://visualstudio.microsoft.com",
Context = new
{
Name = "PullRequest-WIT-App",
Genre = "pr-azure-function-ci"
}
});
}
5. Add WIP in the title to test the functionality of the app. Select Create to create the PR.
6. Once the PR has been created, you will see the status section, with the Work in progress entry which links
to the URL specified in the payload.
7. Update the PR title and remove the WIP text and note that the status changes from Work in progress to
Ready for review.
Next Steps
In this article, you learned the basics of how to create a serverless Azure function that listens for PR events via
service hooks and can post status messages using the status API. For more information about the pull request
status API see the REST API documentation.
Configure a branch policy for an external service.
Configure a branch policy for an external service
5/31/2019 • 2 minutes to read • Edit Online
Prerequisites
An organization in Azure DevOps with a Git repo. If you don't have an organization, sign up to upload and
share code in free unlimited private Git repositories.
A service that posts status to PRs. See Create a pull request status server.
2. Scroll down to find the policy to Require approval from external services. Select Add status policy.
3. Select the service you want to create a policy for from the list. If the status has been posted previously you
can pick it from the list; if it is a new policy you can type in the name of the policy.
Policy requirement determines whether or not this policy is optional or required to complete pull
requests into the branch.
Authorized account is used to enforce that status from only the specified account will be counted
towards the policy fulfillment.
Reset conditions is used to determine when a posted status is no longer valid. If the status posted is
specific to the latest code (i.e. a build), check Reset status whenever there are new changes to reset
the status when the source branch changes.
Policy applicability determines whether this policy applies as soon as a pull request is created, or
whether the policy applies only after the first status is posted to the pull request.
Default display name allows you to specify an optional display name for your policy.
When the service has posted status, the policy will update accordingly. Completion will be blocked until the
policy approves the PR.
When the policy criteria are met, and the service posts a succeeded status, the PR will be approved and
completion will be unblocked.
Summary
In this article, you learned how to configure a branch policy for an external service.
Build multiple branches
8/30/2019 • 8 minutes to read • Edit Online
Azure Pipelines | Azure DevOps Server 2019 | TFS 2018 | TFS 2017
NOTE
In Microsoft Team Foundation Server (TFS) 2018 and previous versions, build and release pipelines are called definitions,
service connections are called service endpoints, stages are called environments, and jobs are called phases.
You can build every commit and pull request to your Git repository using Azure Pipelines or TFS. In this tutorial,
we will discuss additional considerations when building multiple branches in your Git repository. You will learn
how to:
Set up a CI trigger for topic branches
Automatically build a change in topic branch
Exclude or include tasks for builds based on the branch being built
Keep code quality high by building pull requests
Use retention policies to clean up completed builds
Prerequisites
You need a Git repository in Azure Pipelines, TFS, or GitHub with your app. If you do not have one, we
recommend importing the sample .NET Core app into your Azure Pipelines or TFS project, or forking it into
your GitHub repository. Note that you must use Azure Pipelines to build a GitHub repository. You cannot
use TFS.
You also need a working build for your repository.
trigger:
- master
- feature/*
Exclude or include tasks for builds based on the branch being built
The master branch typically produces deployable artifacts such as binaries. You do not need to spend time creating
and storing those artifacts for short-lived feature branches. You implement custom conditions in Azure Pipelines or
TFS so that certain tasks only execute on your master branch during a build run. You can use a single build with
multiple branches and skip or perform certain tasks based on conditions.
YAML
Classic
Edit the azure-pipelines.yml file in your master branch, locate a task in your YAML file, and add a condition to it.
For example, the following snippet adds a condition to publish artifacts task.
- task: PublishBuildArtifacts@1
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
Next steps
In this tutorial, you learned how to manage CI for multiple branches in your Git repositories using Azure Pipelines
or TFS.
You learned how to:
Set up a CI trigger for topic branches
Automatically build a change in topic branch
Exclude or include tasks for builds based on the branch being built
Keep code quality high by building pull requests
Use retention policies to clean up completed builds
Drive Git development from a work item
5/23/2019 • 7 minutes to read • Edit Online
Azure DevOps Services | Azure DevOps Server 2019 | TFS 2018 | TFS 2017
One of the ways your team can drive their development and stay in sync is to link your work items to the objects
created during development, such as branches, commits, pull requests, and builds. You can begin that linking by
creating a branch from one or more work items. Later, you can create pull requests, quickly open commits, and
maintain a record of development operations performed to complete specific work.
IMPORTANT
This article addresses creating new branches and adding links to commits and pull requests to a Git repository hosted on
Azure DevOps. To link to GitHub commits and pull requests, see Link GitHub commits and pull requests to work items.
The Development section records all Git development processes that support completion of the work item. This
section can show your team information needed to take the next development step and minimize navigational
steps to accomplish common development tasks. It also supports traceability, providing visibility into all the
branches, commits, pull requests, and builds related to the work item.
NOTE
The Development section within the work item form is not supported in TFS 2015 and earlier versions. Consider upgrading
to a later TFS version.
From it, you can quickly access branches, pull requests, and commits which are linked to the work item. Also, you
can initiate a pull request for a branch you've created or linked to from the work item.
Prerequisites
You must connect to a project. If you don't have a project yet, create one.
You must be added to a project as a member of the Contributors or Project Administrators security group.
To get added, Add users to a project or team.
To add or modify work items, you must be granted Stakeholder access or higher. For details, see About access
levels.
To view or modify work items, you must have your View work items in this node and Edit work items in
this node permissions set to Allow. By default, the Contributors group has this permission set. To learn more,
see Set permissions and access for work tracking.
To create new tags to add to work items, you must have Basic access or higher and have the project-level
Create new tag definition permissions set to Allow. By default, the Contributors group has this permission
set. Even if the permission is explicitly set for a Stakeholder, they won't have permission to add new tags, as
they are prohibited through their access level.
You must connect to a project. If you don't have a project yet, create one.
You must be added to a project as a member of the Contributors or Project Administrators security group.
To get added, Add users to a project or team.
To add or modify work items, you must be granted Stakeholder access or higher. For details, see About access
levels.
To view or modify work items, you must have your View work items in this node and Edit work items in
this node permissions set to Allow. By default, the Contributors group has this permission set. To learn more,
see Set permissions and access for work tracking.
To create new tags to add to work items, you must have Basic access or higher and have the project-level
Create new tag definition permissions set to Allow. By default, the Contributors group has this permission
set. Even if the permission is explicitly set for a Stakeholder, they won't have permission to add new tags, as
they are prohibited through their access level.
Name the branch and select the repository on which it's based.
Branches you create are automatically linked to the work item.
NOTE
You can only create a branch once you've added files to the main branch, which is always named master . The
system automatically adds a README file to the initial repo created with each new project.
2. The system will open to the repository and branch that you just created.
You can edit a file within the web portal.
Or, if you have extensive file edits or need to add files, then you'll need to work from Visual Studio or other
supported IDE. You'll want to add a new local branch from the branch you just created. For details, see
Update code with fetch and pull, Download changes with fetch. (While any code editing and committing
process will work, we work best with an edition of Visual Studio.)
3. Add or modify files in the branch that you created.
From Visual Studio or other supported IDE, commit and push changes from your local branch to the
repository.
If this is the first time pushing changes from a new branch, you'll need to publish the branch before pushing
your changes. For more details, see Share code with push.
4. Create a pull request from the work item form.
You create a pull request to merge the changes you made to a master branch and get your changes
reviewed by other members of your team.
5. Your view will switch to Code, Pull Requests page. Complete creating the pull request as shown.
NOTE
Once you've created a pull request, you can't create a new pull request for the same branch until you complete the
previous pull request.
Check the box for Squash changes when merging and then complete the merge.
7. Open the work item form or refresh the form, expand the Development section (click the icon), and
you'll see the links that have been added to support the operations you just completed.
To link a work item to an existing object, click the Add links icon and then choose the link type.
Or, you can select it from the Links tab and click the remove link icon.
Related articles
Learn more about tracking work with work items and developing with Git from these resources:
Add work items
Git overview
Link GitHub commits and pull requests to work items
TFVC overview
Create your backlog
Add work items
Git overview
TFVC overview
Create your backlog
Keep in mind that the Development section only appears within the web portal work item form. The work item
tracking experience and forms that appear in Visual Studio or other supported clients will be missing several of the
features that the web portal makes available.
Associated work items in build
With Git commits, any work items that have been linked to a commit will be listed under the Associated work items
in the build summary page.
The link types you can add within the development section are Branch, Build, Changeset, Commit, Pull Request,
and Versioned Item.
To learn more about the links control or to customize the Development links control, see LinksControlOptions
elements, Development links control.
Go get command support in Azure Repos Git
6/19/2019 • 2 minutes to read • Edit Online
Azure Repos
Go is an open-source programming language, also referred to as Golang. In Go, you can use the get command to
download and install packages and dependencies. Azure Repos Git provides support for go get within an Azure
Repos Git repository. With go get , you will be able to download packages with their dependencies named by the
import paths. You can also use the import key word inside a go file to specify the import path, using the same
syntax described in the following sections.
go get dev.azure.com/<organization>/_git/<repo>
You can also import/get a Go package in a subfolder of a repo by appending the subfolder names, as shown in the
following examples.
go get dev.azure.com/<organization>/_git/<repo>/subfolder1
go get dev.azure.com/<organization>/_git/<repo>/subfolder1/subfolder2
[url "https://<user>:<token>@dev.azure.com/<organization>/_git/<repo>"]
insteadOf = https://dev.azure.com/<organization>/_git/<repo>
After this entry is made into your .gitconfig , you can use go get in the following format. Note the .git that
follows the repo name.
go get dev.azure.com/<organization>/_git/<repo>.git
You can also import/get a Go package in a subfolder of a repo by appending the subfolder names, as shown in the
following examples.
go get dev.azure.com/<organization>/_git/<repo>.git/subfolder1
go get dev.azure.com/<organization>/_git/<repo>.git/subfolder1/subfolder2
Import repositories from TFVC to Git
5/31/2019 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 Update 2
You can migrate code from an existing TFVC repository to a new Git repository within the same organization.
While migrating to Git has many benefits, it is an involved process for large TFVC repositories and teams.
Centralized version control systems, like TFVC, behave different than Git in fundamental ways. The switch involves
a lot more than learning new commands. It is a disruptive change that requires careful planning. You need to think
about:
Revising tools and processes
Removing binaries and executables
Training your team
We strongly recommend reading our whitepapers - Centralized version control to Git and TFVC to Git before
starting the migration.
The import experience is great for small simple TFVC repositories. It's also good for repositories that have already
been "cleaned up" as outlined in the previous whitepapers. Those whitepapers also recommend other tools for
more advanced TFVC repository configurations.
5. If you want to migrate history from the TFVC repository, click Migrate history and select the number of
days. You can migrate up to 180 days of history starting from the most recent changeset. A link to the TFVC
repository is added in the commit message of the 1st changeset that is migrated to Git. This makes it easy to
find older history when needed.
6. Give a name to the new Git repository and click Import. Depending on the size of the import, your Git
repository would be ready in a few minutes.
IMPORTANT
Due to the differences in how TFVC and Git store version control history, we recommend that you don't migrate your history.
This is the approach that Microsoft took when it migrated Windows and other products from centralized version control to
Git.
3. If you want to migrate history from the TFVC repository, click Migrate history and select the number of
days. You can migrate up to 180 days of history starting from the most recent changeset. A link to the TFVC
repository is added in the commit message of the 1st changeset that is migrated to Git. This makes it easy to
find older history when needed.
4. Give a name to the new Git repository and click Import. Depending on the size of the import, your Git
repository would be ready in a few minutes.
IMPORTANT
Due to the differences in how TFVC and Git store version control history, we recommend that you don't migrate your history.
This is the approach that Microsoft took when it migrated Windows and other products from centralized version control to
Git.
Troubleshooting
This experience is optimized for small, simple TFVC repositories or repositories that have been prepared for a
migration. This means it has a few limitations.
1. It only migrates the contents of root or a branch. For example, if you have a TFVC project at $/Fabrikam which
has 1 branch and 1 folder under it, a path to import $/Fabrikam would import the folder while
$/Fabrikam/<branch> would only import the branch.
2. The imported repository and associated history (if imported) cannot exceed 1GB in size.
3. You can import up to 180 days of history.
If any of the above is a blocker for your import, we recommend you try external tools like Git-TFS for importing
and reading our whitepapers - Centralized version control to Git and TFVC to Git
Manage branches
8/7/2019 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017
Manage the work in your team's Git repo from the Branches view on the web. Customize the view to track the
branches you care most about so you can stay on top of changes made by your team.
View your repo's branches by selecting Repos, Branches while viewing your repo on the web.
View your repo's branches by selecting Branches while viewing your repo on the web.
If your team uses a forward slash separator in your branch names, you'll see a collapsible tree view for those
branches.
TIP
Using a naming convention for your branches is highly recommended. For suggestions on how to name your branches, see
Adopt a Git branching strategy.
Configure your Git repo to use a different default branch to merge code into when your team creates new pull
requests. This is useful when you want to use a branch other than master for new changes or need to change
your main line of development in your repo.
1. Navigate to your project and select Project settings.
2. Scroll down and select Repositories from the Code section.
3. Select the desired repository and expand the branches.
4. Select the ... beside the desired branch and choose Set as default branch.
1. Select the settings icon while you have your project open to bring up the project administration page.
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017
TIP
Need help creating a new Git branch in your local repo from Visual Studio or the command line? Visit the Git tutorial.
IMPORTANT
Users of TFS 2015 and previous will not have the Branches tab in the Code view. When using those versions, you can create
a new branch in TFS from the Code view by selecting the drop-down next to the branch name and then selecting New
branch.
2. Select the New branch button in the upper right corner of the page.
3. In the Create a branch dialog, enter a name for your new branch, select a branch to base the work off of,
and associate any work items.
4. Select Create branch.
1. View your repo's branches by selecting Branches while viewing your repo on the web.
2. Select the New branch button in the upper right corner of the page.
3. In the Create a branch dialog, enter a name for your new branch, select a branch to base the work off of,
and associate any work items.
4. Select Create branch.
TIP
You will need to fetch the branch before you can see it and swap to it in your local repo.
Delete a Git branch from the web portal
8/7/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017
IMPORTANT
This topic covers deleting a Git branch via the web in Azure DevOps Services and TFS. If you need to delete a Git branch in
your own repo from Visual Studio or the command line, follow these steps in the Azure Repos Git tutorial.
1. Open your repo on the web and select the Branches view.
2. Locate your branch on the branches page. If you don't see it, select All to view all branches and filter the
branches using the Search all branches box in the upper right.
3. Select the trashcan icon next to the branch you want to delete.
Restore a deleted Git branch from the web portal
8/7/2019 • 2 minutes to read • Edit Online
IMPORTANT
This topic covers restoring a deleted Git branch via the web in Azure Repos and TFS 2018. If you need to restore a Git
branch in your own repo from Visual Studio or the command line, push your branch from your local repo to Azure Repos to
restore it.
1. Open your repo on the web and select the Branches view.
2. Search for the exact branch name using the Search all branches box in the upper right.
3. Click the link to Search for exact match in deleted branches. If there is a deleted branch that matches
your search, you will be able to see which commit it pointed to when it was deleted, who deleted it, and
when it was deleted.
4. To restore the branch, select the ... icon next to the branch name and then select Restore branch from the
menu. The branch will be recreated at the last commit to which it pointed. Note that branch policies and
permissions will not be restored.
If you've re-used the same branch name for different commits, you may not see all the commits you're expecting
when you restore the deleted branch. In that case, navigate to the Pushes page of the restored branch to see the
entire history of the branch.
You can navigate to a specific commit, then select New branch from the ... icon. From there, you can use a pull
request, cherry-pick, or merge to get the commits back into the desired branch.
You can navigate to a specific commit, then select New branch from the ... icon. From there, you can use a pull
request, cherry-pick, or merge to get the commits back into the desired branch.
Require branches to be created in folders
8/7/2019 • 2 minutes to read • Edit Online
Planning
Decide on the folder structure you want to allow. As an example, we'll set our repository to enforce the following
rules:
Only master can exist at the repository root.
All users will be allowed to create branches under the features/ and users/ folders.
Administrators will be able to create branches under the releases/ folder.
NOTE
For more examples and information about branch naming strategies, see Adopt a Git branching strategy.
Preparation
You will need the Team Foundation version control command ( tf.exe ) on your computer. Run a Visual Studio
Developer Command Prompt (in Windows, choose Start, choose Visual Studio, then choose the Developer
Command Prompt).
You will need the URL of your account or collection, the name of the project, and the name of the repository.
For this example, we'll use https://fabrikam-fiber.visualstudio.com , FabrikamProject , and FabrikamRepo .
Enforce permissions
Run the following commands in the Developer Command Prompt. Each command is preceded with an
explanation of what it's doing. If you don't have a personal access token cached (for example by signing in to the
Azure DevOps Services web portal) you'll be prompted to login.
First, block the Create Branch permission at the repository root for the project's contributors.
Finally, allow administrators to create a branch called master (in case it ever gets deleted accidentally.
NOTE
For more information, see tf git permission. You can also access help for these commands from the command line by running
tf git /? and tf git permission /? .
4. Type the new name of the branch, for example users/frank/readme-fix. Choose Create branch.
5. Choose the red trashcan icon next to the old branch name to delete it.
NOTE
Any custom permissions or branch policies you had set up will not be migrated.
Lock a branch
8/7/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015
Prevent updates to a Git branch by locking the branch. Locking a branch prevents other users from changing the
existing commit history. Locking also blocks any new commits from being added to the branch by others.
Locking limitations
Locking is ideal for preventing new changes that might conflict with an important merge or to place a branch into
a read-only state. Use branch policies and pull requests instead of locking if you just want to ensure that changes
in a branch are reviewed before they are merged.
Locking does not prevent cloning of a repo or fetching updates made in the branch into your local repo. Share with
your team the reason for the locking of the branch and make sure your team knows what to do to work with the
branch after it is unlocked.
Only the user who locked the branch or a user with Remove Others' Locks permissions for the branch can
remove the lock.
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015
Branch policies help teams protect their important branches of development. Policies enforce your team's code
quality and change management standards.
If you're not using the new navigation preview, select Code, Branches.
2. Locate your branch in the page. You can browse the list or you can search for your branch using the
Search all branches box in the upper right.
3. Open the context menu for the branch by selecting the ... icon. Select Branch policies from the context
menu.
4. Configure your desired policies in the Policies page. See the following sections in this article for
descriptions for each policy type. Once your policies are configured, select Save changes to apply your
new policy configuration.
Require a minimum number of reviewers
Code reviews are a best practice for most software development projects. To require teams to review their
changes before completing a pull request, check Require a minimum number of reviewers.
The basic policy requires that a certain number of reviewers approve the code with no rejections.
If Allow users to approve their own changes is not selected, the creator of the pull request can still vote
Approve on their pull request, but their vote won't count toward the Require a minimum number of
reviewers policy.
If any reviewer rejects the changes, the pull request cannot be completed unless the Allow completion
even if some reviewers vote "Waiting" or "Reject" is selected.
To reset code reviewer votes when new changes are pushed to the source branch, check Reset code
reviewer votes when there are new changes.
When the required number of reviewers approve the pull request, it can be completed.
NOTE
The Allow users to approve their own changes setting only applies to the Require a minimum number of
reviewers policy, and doesn't affect other policies such as Automatically include code reviewers. For example, Jamal
Hartnett creates a pull request with the following policies configured:
Require a minimum number of reviewers is configured with two required reviewers.
Allow users to approve their own changes is not set.
The Fabrikam Team group is a required reviewer, and Jamal is a member of that group.
In this example, since Jamal is part of the Fabrikam Team group, his Approve vote satisfies the required reviewer
policy, but the pull request still requires two additional Approve votes to satisfy the Require a minimum number of
reviewers policy, since his vote doesn't count toward that policy because Allow users to approve their own changes
is not set.
For more information on working with pull request comments, see Pull requests - leave comments.
No fast-forward merge - This merges the commit history of the source branch when the pull request
closes and creates a merge commit in the target branch.
Squash merge - Complete all pull requests with a squash merge, creating a single commit in the target
branch with the changes from the source branch. Learn more about squash merging and how it affects your
branch history.
Build validation
Set a policy requiring changes in a pull request to build successfully with the protected branch before the pull
request can be completed. Even if you're using continuous integration (CI) on your development branches to
catch problems early, build policies reduce build breaks and keep your tests results passing.
When a build validation policy is enabled, a new build is queued when a new pull request is created or when
changes are pushed to an existing pull request targeting this branch. The build policy then evaluates the results
of the build to determine whether the pull request can be completed.
IMPORTANT
Before specifying a build validation policy, you must have a build definition. If you don't have one, see Create a build
definition and choose the type of build that matches your project type.
Choose Add build policy and configure the desired options in the Add build policy window.
For instructions on configuring this policy, see Configure a branch policy for an external service.
These reviewers are automatically added to pull requests that change files along those paths.
If you select Required next to a path entry, then the pull request cannot be completed until:
Every user added as a reviewer for the path approves the changes.
At least one person in every group added to the path approves the changes.
Select Optional if you want to add reviewers automatically, but not require their approval to complete the pull
request.
When the required reviewers approve the code, you can complete the pull request.
In some cases, you need to bypass policy requirements so you can push changes to the branch directly or
complete a pull request even if branch policies are not satisfied. For these situations, grant the desired
permission from the previous list to a user or group. You can scope this permission to an entire project, a repo,
or a single branch. Manage this permission along the with other Git permissions.
IMPORTANT
Use caution when granting these permissions, especially at the repo and project level.
Q&A
Can I push changes directly to a branch after a branch policy is configured?
What is auto-complete?
When are the conditions set in branch policies checked?
Can I use XAML build definitions in branch policies?
What type of wildcard characters are supported when configuring required code reviewers?
Are the required code reviewer paths case-sensitive?
How can I configure multiple users as required reviewers, but only require that one of them approve?
I have the exempt from policy permission set, why am I still seeing policy failures in the pull request status?
Where can I get more information on advanced policy configurations?
Can I push changes directly to a branch after a branch policy is configured?
No. After you set up a required branch policy, you cannot directly push changes to the branch. Changes to the
branch are only made through pull requests.
NOTE
If you have permissions that allow you to bypass branch policies you can push directly to a branch after a required
branch policy is configured.
If you configured optional branch policies, but no required branch policies, you can push changes directly to a branch.
What is auto-complete?
When a pull request is made into a branch with branch policies configured, the Set auto-complete button is
enabled for the pull request. If you don't expect any problems with your changes and you want your pull
request to complete once all policies are met, you can set the pull request to automatically complete.
When are the conditions set in branch policies checked?
Branch policies are re-evaluated on the server as changes are pushed and reviewers vote. If there is a build
triggered by the policy, the build status is set to waiting until the build completes.
Can I use XAML build definitions in branch policies?
You cannot use XAML build definitions in branch policies.
What type of wildcard characters are supported when configuring required code reviewers?
Single asterisks ( * ) are supported, and will match any number of characters, including both forward-slashes (
/ ) and back-slashes ( \ ). Question marks ( ? ) will match any single character.
Examples:
*.sql will match all files with the .sql extension
/ConsoleApplication/* will match all files under the folder named ConsoleApplication
/.gitattributes will match the .gitattributes file in the root of the repo
*/.gitignore will match any .gitignore file in the repo
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 Update 1
Overview
Set up permissions to control who can read and update the code in a branch on your Git repo. You can set
permissions for individual users and groups, and inherit and override permissions as needed from your repo
permissions.
If you're not using the new navigation preview, select Code, Branches.
2. Locate your branch in the page. You can browse the list or you can search for your branch using the
Search all branches box in the upper right.
3. Open the context menu by selecting the ... icon next to the branch name. Select Branch security from the
menu.
Add users or groups to your branch permissions by selecting Add Enter the sign-in address or group alias, then
select Save Changes.
NOTE
These permissions have changed in TFS 2017 Update 1 and Azure DevOps Services. Ensure you are viewing the correct
version of this documentation for permissions by choosing your product version in the upper left corner of the window.
Contribute Users with this permission can push new commits to the
branch and lock the branch.
Exempt from policy enforcement Users with this permission are exempt from the branch policy
set for the branch when completing pull requests and can
override the policies by checking Override branch policies
and enable merge when completing a PR. Users with this
permission can also push to a branch that has branch policies
enabled.
Force Push (Rewrite History and Delete Branches) Can force push to a branch, which can rewrite history. This
permission is also required to delete a branch.
Remove Others' Locks Can remove locks set on branches by other users.
Administer Users with this permission can set branch permissions for
other users, delete the branch, and lock the branch.
Contribute Users with this permission can push new commits to the
branch. Users with this permission cannot rewrite the existing
commits on the branch. Users with this permission can lock
the branch.
Exempt from policy enforcement Users with this permission are exempt from the branch policy
set for the branch.
Rewrite and destroy history (force push) Can force push to a branch. This permission is also required
to delete a branch. Users with this permission can modify the
commit history of a branch.
NOTE
In Azure DevOps Services, the Exempt from policy enforcement permission (which is still available in TFS 2015 through
TFS 2018 Update 2) was removed and its functionality divided into the following two new permissions:
Bypass policies when completing pull requests
Bypass policies when pushing
Users that previously had Exempt from policy enforcement enabled now have the two new permissions enabled instead.
See the following table for more details on these two new permissions.
PERMISSION DESCRIPTION
Contribute Users with this permission can push new commits to the
branch and lock the branch.
Bypass policies when completing pull requests Users with this permission are exempt from the branch policy
set for the branch when completing pull requests and can
opt-in to override the policies by checking Override branch
policies and enable merge when completing a PR.
Bypass policies when pushing Users with this permission can push to a branch that has
branch policies enabled. Note that when a user with this
permission makes a push that would override branch policy,
the push automatically bypasses branch policy with no opt-in
step or warning.
Force Push (Rewrite History and Delete Branches) Can force push to a branch, which can rewrite history. This
permission is also required to delete a branch.
Remove Others' Locks Can remove locks set on branches by other users.
Learn to map your familiar Team Foundation Version
Control (TFVC) commands and workflows to Git
1/25/2019 • 7 minutes to read • Edit Online
Do you plan to adopt Git, are familiar with TFVC actions, and wondering how they map to Git? Both are powerful
and mature source control systems. However, mapping common actions you have grown accustomed to in the one
to the other can be a confusing experience.
This article will not delve deep into the Git commands, as they are well documented in the product documentation,
but show examples to help you make the right decisions, while moving through a typical create -> clone -> branch
-> change -> commit -> push workflow.
Once the repo is created, you are presented with step-by-step instructions to quickly get started.
Click on the `Create a ReadMe file' at the end of the instruction page, to give the repo context and to create some
history.
You only need to clone once per repo, but like TFVC workspaces, you can have multiple clones to isolate in-
progress work. However, branching is typically a better way to isolate changes.
Create a branch
With Git, you are always working in a branch and by default in the "master" branch. You are recommended to
create multiple local branches. It's a process that takes seconds and allows you to seamlessly context switch
between branches and work in isolation. Unlike TFVC branches, which are paths scoped, Git branches are
repository scoped. They are lightweight, can be local only, or shared with others when you are ready to share your
changes.
Consider branching if you need to work in isolation, need to suspend your work, focus on new features, or if you
are planning to conduct a Git pull request.
As a TFVC user, repeat a few times:
Branching is recommended!
Git branching is inexpensive, fast, and powerful!
Git encourages you to use local branches.
Publish local branches to your centralized repository as needed.
Always verify your branch context before making changes.
Name the branch using a common convention such as users/alias/branchname for example:
users/doris/newfeature
Create and switch to a local topic branch, named francis/demo -feature. It is good practice to run a git status first,
to verify that you are on the right branch to start with.
Command Line
Visual Studio
or
Using the pre-baked sample, you will have 13 new files that have been included and staged in the local repository.
Command Line
Visual Studio
git status
Checkin changes and commit locally
In TFVC, you share your changes with a Check In, which sends your pending changes to the server. The Git process
is a bit different. First, you commit to the local repository, creating a commit object (like a changeset), then you push
to send those changes with the server.
You commit the changes to your local repository using git commit , which feels like doing a
Checkin Pending Changes in TFVC. A key difference is that the git commit commits your changes to the local, not
the remote repository.
Command Line
Visual Studio
git commit
To synchronize further updates in your local with the remote repository, you need to push your changes using
git push . The recommended practice using the git command or the Visual Studio IDE is to:
View history
To see the commit, you just created you can review the local history.
Command Line
Visual Studio
For a compact history, use:
git log --oneline
git log
As shown above, git log lists the author, email, date written, and the commit SHA-1 checksum. As a TFVC user
you may want to use the --stat option to include more information, such as file name and change statistics.
You can also view the history of the centralized repository using the Azure DevOps Services web portal.
In the Azure DevOps Services web portal, choose CODE > History or CODE > Explorer > History
At this point, you have successfully explored the create -> clone -> branch -> change -> commit -> push workflow,
based on common TFVC actions.
You also have the option of issuing a pull request, to publish and stage your changes on the server/remote repo at
this point.
Other actions
Switch branches
When working with Git, you do not change branches by switching to separate folders and locations on your
machine. You change the context by doing a checkout , making the entire working directory match the selected
branch or commit. Fast and simple!
Command line
If you forgot what branches you have in your local repository, use git branch to list the default and known
branches.
Keep in mind which branch you are working on! When you work with multiple branches in Git, you switch branches
in place in the same working directory. Switching between branches is a fast operation, and making sure you are on
the right branch at all times is good practice.
Get latest version
There are lots of reasons to want to get updates. For example, when you need to switch context to another project,
refresh your development machine with the latest version of the codebase.
Command line
git pull
or
git fetch
followed by
Always get the latest version and resolve merge conflicts locally.
Undo local changes
There may be a valid reason to revert all revisions you made in your local repository and reset your working
environment to the latest version from the remote repository.
Command line
followed by
followed by
The scenario is synonymous to doing a Get > Latest Version with the
Overwrite writable files that are not checked out and
Overwrite all files if the local version matches the specified version options in TFVC.
Alternatively you can manually delete your local repo - after making a validated copy off course - and then clone
the repository again.
There are a lot more actions and options available to Git users. Here are some useful reference sites for further
reading:
Git commands covered herein, refer to git documentation
Think like (a) Git, a Guide for the Perplexed.
How to undo (almost) anything with Git, by Joshua Wehner
Q&A
What about sync?
"Does the Visual Studio IDE Commit and Sync not magically do all this?", you may be asking yourself.
With magic comes responsibility! Many users dislike the sync as it can sometimes mess up your local history and
add a merge commit on top of your current commit. Once you are in a bad state, you have to revert to the
command line as there is currently no reset support in the IDE.
Authors: Jesse Houwing, Martin Hinshelwood, Mike Fourie, and Willy Schaub from the ALM | DevOps Rangers.
Connect with them here.
(c) 2015 Microsoft Corporation. All rights reserved. This document is provided "as-is." Information and views
expressed in this document, including URL and other Internet Web site references, may change without notice. You
bear the risk of using it.
This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You
may copy and use this document for your internal, reference purposes.
Build pipeline triggers
8/19/2019 • 23 minutes to read • Edit Online
Azure Pipelines | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015
NOTE
In Microsoft Team Foundation Server (TFS) 2018 and previous versions, build and release pipelines are called definitions,
service connections are called service endpoints, stages are called environments, and jobs are called phases.
On the Triggers tab, you specify the events that trigger the build. You can use the same build pipeline for both CI
and scheduled builds.
CI triggers
Continuous integration (CI) triggers cause a build to run whenever a push is made to the specified branches or a
specified tag is pushed.
YAML
Classic
YAML builds are configured by default with a CI trigger on all branches.
YAML builds are configured by default with a CI trigger on all branches.
Branches
You can control which branches get CI triggers with a simple syntax:
trigger:
- master
- releases/*
You can specify the full name of the branch (for example, master ) or a wildcard (for example, releases/* ). See
Wildcards for information on the wildcard syntax. Note: you cannot use variables in triggers, as variables are
evaluated at runtime (after the trigger has fired).
You can specify branches to include and exclude. For example:
In addition to specifying branch names in the branches lists, you can also configure triggers based on tags by
using the following format:
trigger:
branches:
include:
refs/tags/{tagname}
exclude:
refs/tags/{othertagname}
trigger:
branches:
include:
- '*' # must quote since "*" is a YAML reserved character; we want a string
IMPORTANT
When you specify a trigger, it replaces the default implicit trigger, and only pushes to branches that are explicitly configured
to be included will trigger a pipeline. Includes are processed first, and then excludes are removed from that list. If you specify
an exclude but don't specify any includes, nothing will trigger.
Batching CI builds
If you have a lot of team members uploading changes often, you may want to reduce the number of builds you're
running. If you set batch to true , when a build is running, the system waits until the build is completed, then
queues another build of all changes that have not yet been built.
Paths
You can specify file paths to include or exclude. Note that the wildcard syntax is different between branches/tags
and file paths.
When you specify paths, you also need to explicitly specify branches to trigger on.
Tags
In addition to specifying tags in the branches lists as covered in the previous section, you can directly specify tags
to include or exclude:
# specific branch build
trigger:
tags:
include:
- v2.*
exclude:
- v2.0
If you don't specify any tag triggers, then by default, tags will not trigger pipelines.
NOTE
If you specify tags in combination with branch filters that include file paths, the trigger will fire if the branch filter is satisfied
and either the tag or the path filter is satisfied.
NOTE
Triggering on tags is not currently supported for Bitbucket Cloud repos.
IMPORTANT
When you push a change to a branch, the YAML file in that branch is evaluated to determine if a CI build should be run.
IMPORTANT
YAML PR triggers are only supported in GitHub and Bitbucket Cloud. If you are using Azure Repos Git, you can configure a
branch policy for build validation in order to trigger your build pipeline for validation.
NOTE
New pipelines automatically override YAML PR triggers with a setting in the UI. To opt into YAML-based control, you need
to disable this setting on the Triggers tab in the UI.
IMPORTANT
YAML PR triggers are only supported in GitHub. If you are using Azure Repos Git, you can configure a branch policy for
build validation in order to trigger your build pipeline for validation.
You can specify the target branches for your pull request builds. For example, to run pull request builds only for
source branches in a PR that target master and releases/* , you can use the following pr trigger. This
configuration triggers a build upon creation of any pull request where the target branch is set to the master or
releases/* branches. The pipeline also triggers once with any commit coming into the source branch when the
target branch is set to be master or releases/* , while the pull request is active.
pr:
- master
- releases/*
PR triggers will fire for these branches once the pipeline YAML file has reached that branch. For example, if you
add master in a topic branch, PRs to master will not start automatically building. When the changes from the
topic branch are merged into master , then the trigger will be fully configured.
If no pr triggers appear in your YAML file, pull request builds are automatically enabled for all branches, as if you
wrote the following pr trigger. This configuration triggers a build when any pull request is created, and when
commits come into the source branch of any active pull request.
pr:
branches:
include:
- '*' # must quote since "*" is a YAML reserved character; we want a string
IMPORTANT
When you specify a pr trigger, it replaces the default implicit pr trigger, and only pushes to branches that are explicitly
configured to be included will trigger a pipeline. Includes are processed first, and then excludes are removed from that list. If
you specify an exclude but don't specify any includes, nothing will trigger.
You can specify the full name of the branch (for example, master ) or a wildcard (for example, releases/* ). See
Wildcards for information on the wildcard syntax.
You can specify branches to include and exclude. For example:
Note that the wildcard syntax is different between branches/tags and file paths.
You can specify whether additional pushes to a PR should cancel in-progress runs for the same PR. The default is
true .
You can opt out of pull request builds entirely by specifying pr: none .
# no PR builds
pr: none
IMPORTANT
When you create a pull request, or push a change to the source branch of a PR, the YAML file in the source branch is
evaluated to determine if a PR build should be run.
IMPORTANT
Scheduled triggers defined using the pipeline settings UI take precedence over YAML scheduled triggers.
If your YAML pipeline has both YAML scheduled triggers and UI defined scheduled triggers, only the UI defined scheduled
triggers are run. To run the YAML defined scheduled triggers in your YAML pipeline, you must remove the scheduled
triggers defined in the pipeline setting UI. Once all UI scheduled triggers are removed, a push must be made in order for the
YAML scheduled triggers to start running.
Scheduled triggers cause a build to run on a schedule defined using cron syntax.
schedules:
- cron: string # cron syntax defining a schedule
displayName: string # friendly name given to a specific schedule
branches:
include: [ string ] # which branches the schedule applies to
exclude: [ string ] # which branches to exclude from the schedule
always: boolean # whether to always run the pipeline or only if there have been source code changes since
the last run. The default is false.
schedules:
- cron: "0 0 * * *"
displayName: Daily midnight build
branches:
include:
- master
- releases/*
exclude:
- releases/ancient/*
- cron: "0 12 * * 0"
displayName: Weekly Sunday build
branches:
include:
- releases/*
always: true
The first schedule, Daily midnight build, runs a pipeline at midnight every day, but only if the code has changed
since the last run, for master and all releases/* branches, except those under releases/ancient/* .
The second schedule, Weekly Sunday build, runs a pipeline at noon on Sundays, whether the code has changed
or not since the last run, for all releases/* branches.
NOTE
The time zone for cron schedules is UTC, so in these examples, the midnight build and the noon build are at midnight and
noon in UTC.
The schedules are read and updated when the following events occur, and schedules get added to the scheduling
database for the current branch, if the branch criteria is satisfied.
The yaml file is created or updated
A pipeline is created or updated
A new branch is created
Supported cron syntax
Each cron expression is a space-delimited expression with five entries in the following order.
mm HH DD MM DW
\ \ \ \ \__ Days of week
\ \ \ \____ Months
\ \ \______ Days
\ \________ Hours
\__________ Minutes
Minutes 0 through 59
Hours 0 though 23
Days 1 through 31
Months 1 through 12, full English names, first three letters of English
names
Days of week 0 through 6 (starting with Sunday), full English names, first
three letters of English names
NOTE
Each cron schedule has a maximum of 100 pipeline runs per week. If you need more, you can split your cron schedule into
multiple cron schedules that each result in 100 or less pipeline runs per week.
Every Monday - Friday at 3:00 AM (UTC - 5:00 time zone), build branches that meet the features/nc/*
branch filter criteria
The equivalent YAML scheduled trigger is:
schedules:
- cron: "30 21 * * Sun-Thu"
displayName: M-F 3:00 AM (UTC + 5:30) India daily build
branches:
include:
- /features/india/*
- cron: "0 8 * * Mon-Fri"
displayName: M-F 3:00 AM (UTC - 5) NC daily build
branches:
include:
- /features/nc/*
In the first schedule, M -F 3:00 AM (UTC + 5:30) India daily build, the cron syntax ( mm HH DD MM DW ) is
30 21 * * Sun-Thu .
Minutes and Hours - 30 21 - This maps to 21:30 UTC , or 9:30 PM UTC . Since the specified time zone in the
classic editor is UTC + 5:30, we need to subtract 5 hours and 30 minutes from the desired build time of 3:00
AM to arrive at the desired UTC time to specify for the YAML trigger.
Days and Months are specified as wildcards since this schedule doesn't specify to run only on certain days of
the month, or on a specific month.
Days of the week - Sun-Thu - because of the timezone conversion, for our builds to run at 3:00 AM in the UTC
+ 5:30 India time zone, we need to specify starting them the previous day in UTC time. We could also specify
the days of the week as 0-4 or 0,1,2,3,4 .
In the second schedule, M -F 3:00 AM (UTC - 5) NC daily build, the cron syntax is 0 8 * * Mon-Fri .
Minutes and Hours - 0 8 - This maps to 8:00 AM UTC . Since the specified time zone in the classic editor is
UTC - 5:00, we need to add 5 hours from the desired build time of 3:00 AM to arrive at the desired UTC time
to specify for the YAML trigger.
Days and Months are specified as wildcards since this schedule doesn't specify to run only on certain days of
the month, or on a specific month.
Days of the week - Mon-Fri - Because our timezone conversions don't span multiple days of the week for our
desired schedule, we don't need to do any conversion here. We could also specify the days of the week as 1-5
or 1,2,3,4,5 .
IMPORTANT
The UTC time zones in YAML scheduled triggers don't account for daylight savings time.
Every Sunday at 3:00 AM UTC, build the releases/lastversion branch, even if the source or pipeline hasn't
changed
In the first schedule, M -F 3:00 AM (UTC ) daily build, the cron syntax is 0 3 * * Mon-Fri .
Minutes and Hours - 0 3 - This maps to 3:00 AM UTC . Since the specified time zone in the classic editor is
UTC, we don't need to do any time zone conversions.
Days and Months are specified as wildcards since this schedule doesn't specify to run only on certain days of
the month, or on a specific month.
Days of the week - Mon-Fri - because there is no timezone conversion, the days of the week map directly from
the classic editor schedule. We could also specify the days of the week as 1,2,3,4,5 .
In the second schedule, Sunday 3:00 AM (UTC ) weekly latest version build, the cron syntax is 0 3 * * Sun .
Minutes and Hours - 0 3 - This maps to 3:00 AM UTC . Since the specified time zone in the classic editor is
UTC, we don't need to do any time zone conversions.
Days and Months are specified as wildcards since this schedule doesn't specify to run only on certain days of
the month, or on a specific month.
Days of the week - Sun - Because our timezone conversions don't span multiple days of the week for our
desired schedule, we don't need to do any conversion here. We could also specify the days of the week as 0 .
We also specify always: true since this build is scheduled to run whether or not the source code has been
updated.
Scheduled builds are not yet supported in YAML syntax. After you create your YAML build pipeline, you can use
pipeline settings to specify a scheduled trigger.
YAML builds are not yet available on TFS.
Wildcards
When specifying a branch or tag, you may use an exact name or a wildcard. Wildcards patterns allow * to match
zero or more characters and ? to match a single character. For branches and tags, a wildcard may appear
anywhere in the pattern.
For paths, you may include * as the final character, but it doesn't do anything differently from specifying the
directory name by itself. You may not include * in the middle of a path filter, and you may not use ? .
trigger:
branches:
include:
- master
- releases/*
- feature/*
exclude:
- releases/old*
- feature/*-working
paths:
include:
- '*' # same as '/' for the repository root
exclude:
- 'docs/*' # same as 'docs/'
Q&A
How do I protect my Git codebase from build breaks?
If your code is in a Git repo on Azure Repos or Team Foundation Server, you can create a branch policy that runs
your build. See Improve code quality with branch policies. This option is not available for GitHub repos.
My build didn't run. What happened?
Someone must view a page in your organization regularly for CI and scheduled builds to run. It can be any page,
including, for example, Azure Pipelines.
Your organization goes dormant five minutes after the last user signed out of Azure DevOps. After that, each of
your build pipelines will run one more time. For example, while your organization is dormant:
A nightly build of code in your organization will run only one night until someone signs in again.
CI builds of an Other Git repo will stop running until someone signs in again.
The YAML file in my branch is different than the YAML file in my master branch, which one is used?
For CI triggers, the YAML file that is in the branch you are pushing is evaluated to see if a CI build should be
run.
For PR triggers, the YAML file that is in the source branch of the PR is evaluated to see if a PR build should be
run.
Do I need an agent?
You need at least one agent to run your build or release. Get an agent for Linux, macOS, or Windows.
I'm having problems. How can I troubleshoot them?
See Troubleshoot Build and Release.
I can't select a default agent pool and I can't queue my build or release. How do I fix this?
See Agent pools.
I use TFS on-premises and I don't see some of these features. Why not?
Some of these features are available only on Azure Pipelines and not yet available on-premises. Some features are
available on-premises if you have upgraded to the latest version of TFS.
Resolve work items on commit
9/3/2019 • 2 minutes to read • Edit Online
Azure Repos
Close work items by mentioning keywords in commit messages. When you mention a work item in a commit that
makes it to the default branch via one of the supported workflows, we will attempt to resolve that work item.
Keywords
The three supported keywords to trigger a resolution mention are fix , fixes , and fixed (case insensitive).
Optionally, a colon can follow the keyword. Most forms of punctuation can precede or proceed the resolution
mention, excluding another pound sign (#).
Examples
Fixes #123
NOTE
Each work item to be closed must include both a supported keyword and the work item number. Comma separated lists such
as fixes #123,124,125 after a keyword will only resolve the first work item. This is done to mitigate the amount of
accidental resolution that could occur.
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | VS 2017 | VS 2015
Azure DevOps Services and TFS support both annotated and lightweight tags. Lightweight tags are a pointer to
specific commit, while annotated tags contain more information such as the tagger, message, and date. You can
create annotated tags using the web portal, and starting with Visual Studio 2017 Update 6, you can create both
lightweight and annotated tags from within Visual Studio. For more information on Git tags, see 2.6 Git Basics -
Tagging from the Pro Git book.
This article provides an overview of working with Git tags in Azure DevOps Services, TFS, and Visual Studio.
IMPORTANT
The Tags view in Visual Studio was introduced in Visual Studio 2017 Update 6. If you are on versions earlier than this, you
can view and create tags from the history and commit details views starting with Visual Studio 2015, but you won't be able
to perform the operations in the Tags view as described in this article.
NOTE
Project URLs have changed with the release of Azure DevOps Services and now have the format
dev.azure.com/{your organization}/{your project} , but you can still use the existing visualstudio.com format. For
more information, see VSTS is now Azure DevOps Services.
You can view tags in the Tags view and in the Commits view in the web portal.
NOTE
Project URLs have changed with the release of Azure DevOps Services and now have the format
dev.azure.com/{your organization}/{your project} , but you can still use the existing visualstudio.com format. For
more information, see VSTS is now Azure DevOps Services.
Visual Studio
You can view tags in the Tags view and in the History view.
View tags in the Tags view
1. To view all tags in a repo, select Tags from the Home view.
Annotated tags display a tooltip that contains the tag name, tagger, tag date, and message. Lightweight tags
have only the tag name in the tooltip.
For more information about the tagged commit, right-click the tag and select View Commit Details.
3. To filter the list of tags, type a search term into the Type here to filter the list box.
To retrieve the current list of tags from the source repo, perform a fetch operation.
View tags in the History view
You can also view tags in the History view, for example by navigating to the Branches view, right-clicking the
desired branch, and choosing View History. The red shapes are branches, and the green shapes are tags.
Create tag
To create a tag, you must have the Create Tag permission, which is included by default in the Contributors group
and higher.
You can create annotated tags using the web portal from both the Tags view and the Commits view.
IMPORTANT
You can only create annotated tags in the web portal. To create a lightweight tag, you can use Git command line or Visual
Studio.
2. Specify a Name, select the branch to Tag from, enter a Description (required since you are creating an
annotated tag), and select Create.
You can create annotated tags using the web portal from both the Tags view and the Commits view.
IMPORTANT
You can only create annotated tags in the web portal. To create a lightweight tag, you can use Git command line or Visual
Studio.
2. Specify a Name, select the branch to Tag from, enter a Description (required since you are creating an
annotated tag), and select Create.
3. The new tag is displayed in the tag list.
Visual Studio
You can create both annotated and lightweight tags in Visual Studio from both the Tags view and the History
view. To create an annotated tag, provide both a name and a message when creating the tag. To create a
lightweight tag, omit the message and supply only a name.
Create tags from the Tags view
1. Select New Tag in the Tags view to create a new tag.
2. To create a tag against the tip of the current branch, specify a name in the Enter a tag name box, optionally
provide a tag message, and select Create Tag.
To select the branch to create the tag from, clear the Create tag against tip of current branch check box,
and select a branch from the Select a branch drop-down.
3. The new tag is created locally. Right-click the new tag and choose Push to push it to the remote repo. Select
Push All to push all new local tags to the remote repo.
Create tags from the History view
1. To create a tag directly from the history view, right-click the desired commit and choose Create Tag.
Delete tag
IMPORTANT
Use caution when deleting tags from your repo. If the repo has been pulled, forked, or cloned by another user, the tag will
still exist in their copy of the repo. You should only delete local tags, or if you are sure that the repo hasn't been pulled,
cloned, or forked since you created your tag.
To delete a tag, you must have the Force Push permission at the Repository level or the All tags level (which
inherits its permissions from the repository level if not explicitly set).
Delete a tag in the remote repo
The steps in this procedure show you how to delete a tag in the remote repo using the Azure DevOps Services
web portal.
1. To delete a tag, select the ellipsis to the right of the tag name and choose Delete tag.
3. The tag is deleted, and won't be displayed the next time you navigate to the Tags view.
3. The tag is deleted, and won't be displayed the next time you navigate to the Tags view.
Visual Studio
The steps in this procedure show you how to delete a tag in the local repo using Visual Studio 2017 Update 6.
1. Right-click the tag to delete and choose Delete Locally
IMPORTANT
If your tag has already been pushed to the remote repo, you should not delete it. If the repo has been pulled, forked, or
cloned by another user, the tag will still exist in their copy of the repo. You should only delete local tags.
2. Specify a Name, optionally select any Work items to link, and choose Create branch.
3. The branch is created and you are taken to the new branch in the web portal.
1. To create a branch from a tag, select the ellipsis to the right of the tag name and choose New branch.
2. Specify a Name, optionally select any Work items to link, and choose Create branch.
3. The branch is created and you are taken to the new branch in the web portal.
Visual Studio
1. To create a branch from a tag, right-click the tag and choose New Local Branch From. You can also choose
Create Branch From Tag.
2. Specify a branch name, verify the desired tag, and choose Create Branch. To checkout the new branch after
it is created, choose Checkout branch.
3. To view your newly created branch, select Branches from the Home view.
4. Note that your new branch is created locally. To push the branch, right-click it and choose Push Branch.
1. To view the history for a tag, select the ellipsis to the right of the tag name and choose View history.
2. You are taken to the commits view for the tag.
Visual Studio
1. To view the history for a tag, right-click the tag and choose View History.
2. The history is displayed in the History view.
RPC failures and http.postBuffer
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | TFS 2013
If you see an RPC failed error during git push , such as:
error: RPC failed; result=22, HTTP code = 404
error: RPC failed; result=22, HTTP code = 411
Unable to rewind rpc post data - try increasing http.postBuffer error: RPC failed; result=56, HTTP code = 0
... and search for help on Stack Overflow or MSDN forums, you'll see a lot of old recommendations to set
http.postBuffer .
Don't do it! At least not blindly. First, review the suggestions in this article.
Upgrade Git
If you're still running a Git client that's version 2.8 or older, you should upgrade Git first. There are a bug fixes in
newer versions of Git that should obviate the need to set http.postBuffer .
We had enough support requests from internal users and external customers hitting bugs in older versions of Git
that we decided to add a server-side reminder to Azure DevOps Services/TFS.
c:\mydir>git fetch
remote: Microsoft (R) Visual Studio (R) Team Services
remote: We noticed you're using an older version of Git. For a better experience, upgrade to the latest version
at https://git-scm.com/downloads
remote: Found 4 objects to send. (6 ms)
Unpacking objects: 100% (4/4), done.
Check hotfixes
Check if these hotfixes are applicable if your TFS server is running Windows 2012 R2 or earlier:
A large file upload or a large repository clone fails on VSO in Windows Server 2012 R2
Pushing large files to Team Foundation Server by Git client hangs
http.postBuffer questions
Is setting http.postBuffer harmful?
In our experience, it's more unnecessary than harmful, but there are a few negative side effects:
Increasing it above the default may increase latency for larger pushes (since the client will buffer the HTTP
request into larger chunks).
If you set it larger than the HTTP chunk size limit for your HTTP server (e.g. maxAllowedContentLength and
maxRequestLength in web.config for TFS servers), then all pushes larger than the chunk size limit will start
failing.
How do I unset http.postBuffer if I've already set it?
To check if it's set, run:
As well as in your repo level .git/config (which overrides the global setting):
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 Update 2
Overview
Visual Studio's Team Explorer lets you perform most common Git tasks you'll need for your day to day work right
from Visual Studio. Open Team Explorer through the View menu in Visual Studio, or with the Ctrl+, Ctrl+M
hotkey.
Team Explorer and the Git command line work great together. When you make updates and perform commands
through one interface, you'll see those changes reflected in the other.
Git Installation instructions are available if you don't have Git installed on your computer.
TIP
Windows users: If you aren't using Visual Studio, installing Git for Windows will set up the Git credential manager for
Windows. The credential manager makes it easy to authenticate with Azure Repos.
While in Visual Studio, open a command prompt in your repo from Team Explorer's Connect view. Right-click on
your local repo and select Open Command Prompt
IMPORTANT
Some commands require having specific Git permissions in Azure Repos to complete.
Repos
HOW DO I ? GIT COMMAND LINE VISUAL STUDIO
Create a repo in a new folder git init foldername Select the Connect button ( ) in
Team Explorer to open the Connect
view, then select New under Local Git
repositories
Create a repo with code in an existing git init foldername Create the repo from the command
folder git add --all line, then open Team Explorer's
git commit -m "Initial commit" Connect view and select Add under
Local Git repositories
HOW DO I ? GIT COMMAND LINE VISUAL STUDIO
Create a repo from an existing Visual git init foldername Open the solution and select Publish (
Studio solution cd foldername ) from the status bar in the
git add --all lower right.
git commit -m "Initial commit"
Create a new repo in your Project Not applicable From the web, select Repos (or Code if
you haven't enabled the new navigation
preview), then select the drop-down
next to the current repo name and
choose New Repository...
Clone a repo into a local folder git clone URL foldername Select Clone under Local Git
repositories in Team Explorer's
Connect view
Clone a repo in your Project git clone URL foldername Open the Connect view in Team
Explorer and right click the Git repo in
your Project under the account name.
Select Clone...
Add an existing repo to Visual Studio Not applicable Open the solution file in Visual Studio
(this will automatically add the repo to
Team Explorer) or select Add under
Local Git repositories in the Connect
view
Delete the Git repo and history, but Delete the hidden .git folder created at Delete the hidden .git folder created at
keep the current version of the files the root of the repo the root of the repo from Windows
Explorer or the command line
Delete a local repo and all files Delete the folder containing your repo Close any open solutions using files in
from your computer's filesystem the repo, then delete the folder
containing your repo from your
computer's filesystem.
Delete a repo in your Project Not applicable Select the settings icon ( ) in Azure
DevOps Services/TFS, then select the
Version Control tab. Find the Git
repository to delete and select the ...
next to the name. Choose Delete
Repository from the options.
Add a remote git remote add name url Open the repository using the Connect
view in Team Explorer, then open the
Settings view in Team Explorer. Select
Repository Settings, and select Add
under Remotes
Update a remote git remote set-url name url Open the repository using the Connect
view in Team Explorer, then open the
Settings view in Team Explorer. Select
Repository Settings, and select Edit
under Remotes
Learn more:
Create a new repo Clone an existing repo
Share your code in Git with the command line
Share your code in Git with Visual Studio 2015
Share your code in Git with Visual Studio 2013
Create a new repo in your Project
Delete a repo in your Project
Branches
HOW DO I ? GIT COMMAND LINE VISUAL STUDIO
Create a new branch git branch branchname Open the Branches view in Team
Explorer, then right-click a branch and
choose New Local Branch From...
Swap to a different branch git checkout branchname Open the Branches view in Team
Explorer, then double click a local
branch. Alternatively, click the current
branch name from the status bar and
select a different branch.
Create and switch to a new branch git checkout -b branchname Open the Branches view in Team
Explorer, then right-click a branch and
choose New Local Branch From...
Delete a local branch git branch -d branchname Open the Branches view in Team
Explorer, then right-click the branch and
select Delete. You must be checked out
to a different branch than the one you
want to delete.
Delete a remote branch git push origin --delete branchname Open the Branches view in Team
Explorer, expand the remote that has
the branch you want to delete. Right-
click the remote and select Delete
Branch from Remote
Lock a branch, preventing updates to it From the web, select the Branches tab Same as command line
while viewing your repo. Select the ...
next to the branch you want to lock
and choose Lock. Unlock the branch
with Unlock
Set a default branch in your Azure Select the settings icon on the web ( Same as command line
DevOps Services/TFS repo ), then select the Version Control tab.
Select your Git repository, then select
the ... next to the branch name and
choose Set as default branch
Set a compare branch for pull requests From the web, select the Branches tab Same as command line
in your Azure DevOps Services/TFS while viewing your repo. Select the ...
repo next to the branch you want to lock
and choose Compare branch
Learn more:
Create and manage your work in branches
Managing your Git branches in Azure DevOps Services/TFS
Delete a Git branch on your Azure DevOps Services/TFS repo
Lock and unlock an Azure DevOps Services/TFS branch
Commits
HOW DO I ? GIT COMMAND VISUAL STUDIO
Create a new commit git commit -m "message" Open the Changes view in Team
Explorer. Stage changes by right-
clicking on the modified files and
selecting Stage. Enter a commit
message and select Commit Staged.
Amend the last commit with staged git commit --amend -m "Updated Open the Changes view in Team
changes message" Explorer, stage your changes, then
select Amend Previous Commit from
the Actions drop-down.
Stage all file changes git add --all Open the Changes view in Team
Explorer. Select the + icon in the
Changes list to stage all changes for
the next commit.
Stage a specific file change git add filename Open the Changes view in Team
Explorer. Stage changes by right-
clicking on the changed file and
selecting Stage.
Review unstaged changes git status --untracked Open the Changes view in Team
Explorer. Unstaged changes are listed
under Changes section.
Tag a commit git tag -a tagname -m "description" Open the Changes view in Team
Explorer, then choose View history..."
from the Action drop-down. Locate the
commit in the History view, then right-
click and select Create Tag
Learn more:
Save your work with commits
Compare the current contents of a git diff HEAD filename Right-click on the change in the
single file and the contents in the last Changes view in Team Explorer and
commit select Compare with unmodified.
Compare your current version with a git diff branchname Right-click on a file in Solution Explorer
branch and select View History..., then select
both on the latest commit on your
current branch and the latest commit
on the remote branch. Right-click and
select Compare
Compare changes between two git diff branchname1 branchname2 Right-click on a file in Solution Explorer
branches and select View History..., then select
the most recent commits for both
branches. Right-click and select
Compare
Learn more:
Compare versions and review history
Sync changes
HOW DO I ? GIT COMMAND VISUAL STUDIO
Download new branches and commits git fetch Open the Sync view from Team
from a remote repo, but do not merge Explorer and select Fetch.
them into your local branches
Merge updates from a remote repo git pull remote branchname While working on the branch in your
into your local repo local repo, open the Sync view in Team
Explorer, then select Pull.
Publish a local branch to a remote repo git push -u remote branchname Open the Sync view in Team Explorer
and select Publish under Outgoing
Commits.
Synchronize your local branch with a git pull remote branchname Open the Sync view in Team Explorer.
remote branch, pushing your local git push -u remote branchname Select Sync.
changes and pulling remote ones
Force push a branch, rewriting the git push --force -u origin Use command line
remote branch history with the history remote_branchname
of your current branch
Learn more:
Share code with push
Update your code with fetch and pull
Resolve merge conflicts
Merge a branch into the current branch git merge branchname In the Team Explorer Branches view,
right-click the branch you want to
merge and select Merge From... Verify
the options set and select Merge.
Merge a remote branch into the git pull origin branchname In the Team Explorer Branches view,
current branch right-click the remote branch you want
to merge and select Merge From...
Verify the options set and select
Merge.
Rebase your current branch onto the git rebase branchname In the Team Explorer Branches view,
history of another branch right-click the branch you want to
rebase your current branch changes
onto and select Rebase Onto.."
Do an interactive rebase of the last n git rebase -i HEAD~n (Linux and Use command line
commits macOS)
git rebase -i "HEAD^n" (Windows)
Cherry-pick a commit into the current git cherry-pick commitID Open the Changes view in Team
branch Explorer, then choose View history..."
from the Action drop-down. Locate the
commit in the History view, then right-
click and select Cherry-pick
Learn more:
Resolve merge conflicts
Catch up and replay changes with rebase
Copy changes with cherry-pick
Undo
WARNING
If you are not an experienced Git user, exercise caution when using the reset command. Learn more
Revert all changes and roll back to the git reset --hard HEAD Open the Changes view in Team
most recent commit Explorer. Select Actions and choose
**View History from the drop-down.
Right-click the commit where the
branch is currently located and select
Reset and Delete changes....
Revert staging of files, but keep file git reset --mixed HEAD Open the Changes view in Team
changes Explorer. Select Actions and choose
**View History from the drop-down.
Right-click the commit where the
branch is currently located and select
Reset and Keep changes....
HOW DO I ? GIT COMMAND VISUAL STUDIO
Delete untracked files git clean -f In the Changes view in Team Explorer,
right-click the files to remove under
Changes marked with [add] and select
Delete.
Reset your local branch to the most git reset --hard remote/branchname Right-click the branch from Team
recent commit on a remote branch (for example, git reset --hard Explorer's Branches view and select
origin/master) Reset and Delete changes....
Revert a commit pushed to a remote git revert commitID Open the Changes view in Team
repository Explorer. Select Actions and choose
**View History from the drop-down.
Right-click the commit to revert and
select Revert.
Learn more:
Undo changes and commits
Syntax guidance for basic Markdown usage
7/29/2019 • 14 minutes to read • Edit Online
Azure DevOps Services | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015
IMPORTANT
Make sure that you select the correct version of this article for Azure DevOps Services or Azure DevOps Server, renamed
from Team Foundation Server (TFS). The version selector is located above the table of contents.
Here you can find some basic Markdown syntax guidance and specific guidance for using Markdown in Azure
DevOps features. You can use both common Markdown conventions and GitHub-flavored extensions.
Having the right guidance at the right time is critical to success. Use Markdown to add rich formatting, tables, and
images to your project pages, README files, dashboards, and pull request comments.
For additional syntax that's supported for Wiki pages, see Wiki Markdown guidance.
You can provide guidance in the following areas using Markdown:
Project wiki
Publish code as wiki
Markdown widget added to a dashboard
Project page or Welcome pages
Repository README files
Pull request comments
Definition of Done (Kanban board)
Project wiki
Markdown widget added to a dashboard
Project page or Welcome pages
Repository README files
Pull request comments
Definition of Done (Kanban board)
NOTE
Rich Markdown rendering in code repositories is supported for TFS 2018.2 and later versions. You can create rich
README.md files in the code repositories. The Markdown rendering of the MD files in code repositories supports HTML tags,
block quotes, emojis, image resizing, and mathematical formulas. There is parity in Markdown rendering in Wiki and MD files
in code.
Headers
Structure your comments using headers. Headers segment longer comments, making them easier to read.
Start a line with a hash character # to set a heading. Organize your remarks with subheadings by starting a line
with additional hash characters, for example #### . Up to six levels of headings are supported.
Example:
# This is a H1 header
## This is a H2 header
### This is a H3 header
#### This is a H4 header
##### This is a H5 header
Result:
Result: Add lines between your text with the Enter key. This spaces your text better and makes it easier to read.
Example - Markdown file or widget:
Result:
Add two spaces prior to the end of the line.
Space is added in between paragraphs.
Block quotes
Quote previous comments or text to set the context for your comment or text.
Quote single lines of text with > before the text. Use many > characters to nest quoted text. Quote blocks of
lines of text by using the same level of > across many lines.
Example:
Result:
Horizontal rules
To add a horizontal rule, add a line that's a series of dashes --- . The line above the line containing the --- must
be blank.
Example:
above
----
below
Result:
above
below
NOTE
There is no Markdown syntax that supports underlining text. Within a wiki page, you can use the HTML <u> tag to
generate underlined text. For example, <u>underlined text</u> yields underlined text.
NOTE
There is no Markdown syntax that supports underlining text. Within a wiki page in TFS 2018.2 and later versions, you can
use the HTML <u> tag to generate underlined text. For example, <u>underlined text</u> yields underlined text.
NOTE
There is no Markdown syntax that supports underlining text.
Example:
Use _emphasis_ in comments to express **strong** opinions and point out ~~corrections~~
**_Bold, italicized text_**
**~~Bold, strike-through text~~**
Result:
Use emphasis in comments to express strong opinions and point out corrections
Bold, italicized text Bold, strike-through text
Code highlighting
Highlight suggested code segments using code highlight blocks. To indicate a span of code, wrap it with three
backtick quotes ( ``` ) on a new line at both the start and end of the block. To indicate code inline, wrap it with one
backtick quote ( ` ).
Example:
```
sudo npm install vsoagent-installer -g
```
Result:
To install the Microsoft Cross Platform Build & Release Agent, run the following: `$ sudo npm
install vsoagent-installer -g`.
Result:
To install the Microsoft Cross Platform Build & Release Agent run the following command:
$ sudo npm install vsoagent-installer .
Within a Markdown file, text with four spaces at the beginning of the line automatically converts to a code block.
Set a language identifier for the code block to enable syntax highlighting for any of the supported languages.
``` language
code
```
Additional examples:
``` js
const count = records.length;
```
``` csharp
Console.WriteLine("Hello, World!");
```
Console.WriteLine("Hello, World!");
Tables
Organize structured data with tables. Tables are especially useful for describing function parameters, object
methods, and other data that has a clear name to description mapping. You can format tables in pull requests, wiki,
and Markdown files such as README files and Markdown widgets.
Place each table row on its own line
Separate table cells using the pipe character |
The first two lines of a table set the column headers and the alignment of elements in the table
Use colons ( : ) when dividing the header and body of tables to specify column alignment (left, center, right)
To start a new line, use the HTML break tag ( <br/> ) (Works within a Wiki but not elsewhere)
Make sure to end each row with a CR or LF.
A blank space is required before and after work item or pull request (PR ) mentions inside a table cell.
Example:
| Heading 1 | Heading 2 | Heading 3 |
|-----------|:-----------:|-----------:|
| Cell A1 | Cell A2 | Cell A3 |
| Cell B1 | Cell B2 | Cell B3<br/>second line of text |
Result:
Lists
Organize related items with lists. You can add ordered lists with numbers, or unordered lists with just bullets.
Ordered lists start with a number followed by a period for each list item. Unordered lists start with a - . Begin
each list item on a new line. In a Markdown file or widget, enter two spaces prior to the line break to begin a new
paragraph, or enter two line breaks consecutively to begin a new paragraph.
Ordered or numbered lists
Example:
1. First item.
2. Second item.
3. Third item.
Result:
1. First item.
2. Second item.
3. Third item.
Bullet lists
Example:
- Item 1
- Item 2
- Item 3
Result:
Item 1
Item 2
Item 3
Nested lists
Example:
1. First item.
- Item 1
- Item 2
- Item 3
1. Second item.
- Nested item 1
- Nested item 2
- Nested item 3
Result:
1. First item.
Item 1
Item 2
Item 3
2. Second item.
Nested item 1
Nested item 2
Nested item 3
Links
In pull request comments and wikis, HTTP and HTTPS URLs are automatically formatted as links. You can link to
work items by entering the # key and a work item ID, and then choosing the work item from the list.
Avoid auto suggestions for work items by prefixing # with a backslash ( \ ). This can be useful if you want to use #
for color hex codes.
In Markdown files and widgets, you can set text hyperlinks for your URL using the standard Markdown link syntax:
When linking to another Markdown page in the same Git or TFVC repository, the link target can be a relative path
or an absolute path in the repository.
Supported links for Welcome pages:
Relative path: [text to display](/target.md)
Absolute path in Git: [text to display](/folder/target.md)
Absolute path in TFVC: [text to display]($/project/folder/target.md)
URL: [text to display](http://address.com)
Example:
Result:
C# language reference
Source control relative links
Links to source control files are interpreted differently depending on whether you specify them in a Welcome page
or a Markdown widget. The system interprets relative links as follows:
Welcome page: relative to the root of the source control repository in which the welcome page exists
Markdown widget: relative to the team project collection URL base
For example:
/BuildTemplates/AzureContinuousDeploy.11.xaml /DefaultCollection/Fabrikam
Fiber/_versionControl#path=$/Tfvc
Welcome/BuildTemplates/AzureContinuousDeploy.11.xaml
./page-2.md /DefaultCollection/Fabrikam
Fiber/_versionControl#path=$/Tfvc Welcome/page-2.md
Anchor links
Within Markdown files, anchor IDs are assigned to all headings when rendered as HTML. The ID is the heading
text, with the spaces replaced by dashes (-) and all lower case. In general, the following conventions:
Punctuation marks and leading white spaces within a file name are ignored
Upper case letters are converted to lower
Spaces between letters are converted to dashes (-).
Example:
Result:
The syntax for an anchor link to a section...
The ID is all lower case, and the link is case sensitive, so be sure to use lower case, even though the heading itself uses
upper case.
You can also reference headings within another Markdown file:
[text to display](./target.md#heading-id)
[text to display](/page-name#section-name)
Images
To highlight issues or make things more interesting, you can add images and animated GIFs to the following in
your pull requests:
Comments
Markdown files
Wiki pages
Use the following syntax to add an image:
![Text](URL)
The text in the brackets describes the image being linked and the URL points to the image location.
Example:
Result:
The path to the image file can be a relative path or the absolute path in Git or TFVC, just like the path to another
Markdown file in a link.
Relative path: ![Image alt text](./image.png)
Absolute path in Git: ![Image alt text](/_img/markdown-guidance/image.png)
Absolute path in TFVC: ![Image alt text]($/project/folder/_img/markdown-guidance/image.png)
Resize image: ![Image alt text]($/project/folder/_img/markdown-guidance/image.png =WIDTHxHEIGHT)
- [ ] A
- [ ] B
- [ ] C
- [x] A
- [x] B
- [x] C
Result:
NOTE
A checklist within a table cell isn't supported.
Emoji
In pull request comments and wiki pages, you can use emojis to add character and react to comments in the
request. Enter what you're feeling surrounded by : characters to get a matching emoji in your text. The full set of
emojis are supported.
In pull request comments, you can use emojis to add characters and react to comments in the request. Enter what
you're feeling surrounded by : characters to get a matching emoji in your text. The full set of emojis are
supported.
Example:
:smile:
:angry:
Result:
Result:
:smile: :) :angry:
To insert one of the following characters, prefix with Some examples on inserting special characters:
a \ (backslash).
Enter \\ to get \
\ , backslash
Enter \_ to get _
` , backtick
_ , underscore Enter \# to get #
{} , curly braces Enter \( to get (
[] , square brackets
Enter \. to get .
() , parentheses
# , hash mark
Enter \! to get !
+ , plus sign
- , minus sign (hyphen)
. , period
! , exclamation mark
Attachments
In pull request comments and wiki pages, you can attach files to illustrate your point or to give more detailed
reasoning behind your suggestions. To attach a file, drag and drop it into the comment field or wiki page edit
experience. You can also select the paper-clip icon in the upper right of the comment box or the format pane in
wiki page.
In pull request comments, you can attach files to illustrate your point or to give more detailed reasoning behind
your suggestions. To attach a file, drag and drop it into the comment field. You can also select the paper-clip icon in
the upper right of the comment box.
NOTE
Attachments in pull requests is available with TFS 2017.1 and later versions.
If you have an image in your clipboard, you can paste it from the clipboard into the comment box or wiki page and
it renders directly into your comment or wiki page.
Attaching non-image files creates a link to the file in your comment. Update the description text between the
brackets to change the text displayed in the link. Attached image files render directly into your comment or wiki
pages. After you save or update a comment or wiki page with an attachment, you can see the attached image(s)
and can select links to download attached files.
Attachments support the following file formats.
Images PNG (.png), GIF (.gif), JPEG (both .jpeg and .jpg), Icons (.ico)
NOTE
Not all file formats are supported within pull requests, such as Microsoft Office Message (.msg) files.
NOTE
This feature is supported within Wiki pages and pull requests for TFS 2018.2 or later versions.
$
\alpha, \beta, \gamma, \delta, \epsilon, \zeta, \eta, \theta, \kappa, \lambda, \mu, \nu, \omicron, \pi, \rho,
\sigma, \tau, \upsilon, \phi, ...
$
$\Gamma, \Delta, \Theta, \Lambda, \Xi, \Pi, \Sigma, \Upsilon, \Phi, \Psi, \Omega$
Result:
$$
A_{triangle}=\frac{1}{2}({b}\cdot{h})
$$
Result:
$$
\int_0^\infty \mathrm{e}^{-x}\,\mathrm{d}x
$$
Result:
Related articles
Project page or Welcome pages
README files
Markdown widget
Dashboards
Widget catalog
Add and edit Wiki pages
Frequently Asked Git Questions
5/10/2019 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015
Is there an easy way to get a remote branch downloaded into my local repository?
As long as you have an origin repository configured (which happens automatically via git clone ), when you
checkout a branch that doesn't exist locally Git will see if there is a remote branch with the same name. If there is,
Git will create a local branch with a reference to the remote branch of that name. Then you can git pull to
download the commits and have Git catch up on the branch history locally.
How can I find out which branch I am working in?
git branch with no arguments shows the local branches and highlights the one you are checked out on. In Visual
Studio, the status bar also displays the current branch when you are working with a project stored in a local Git
repository.
When should you make Git commits?
This is up to you and your team. An accepted practice is to make separate commits for logically separate changes.
Think of commits as entries in a logbook-whenever you've made a change that's worth noting, record it in a
commit. A popular option is to allow everyone to commit locally as much as they want, but before they push the
local commits, they squash them first through rebasing. This gives users a lot of personal flexibility to make
frequent commits while keeping the commit history streamlined.
If every branch retains its full commit history even when merged into master, doesn't that make the commit
history of master hard to follow over time?
Large projects with many commits and a range of contributors can result in commit histories for the master
branch that represent the development history of the topic branches merged into master more than the
development history of the overall project. Git provides a facility for condensing commits on branches through
squashing commits and rebasing. Squashing commits makes the commit history on a branch less verbose and
makes for a simpler commit history on the master branch once merged.
How can I find out who made a specific change to a file in my Git repository?
The git blame command can quickly track down who made a particular change to a file. From your local
repository, you can run git blame with the -L parameter specifying which lines of interest. Blame produces
formatted output showing the commit that last updated the line as well as the name of the person who made the
commit.
> git blame foo.js -L 20,+40 # show the blame output for the next forty lines starting at line 20
215d1108 (Francis Totten 2015-11-21 09:54:23 -0800 20) line 20 of the code
215d1108 (Francis Totten 2015-11-21 09:54:23 -0800 21) line 21 of the code
215d1108 (Francis Totten 2015-11-21 09:54:23 -0800 22) line 22 of the code
Blame does the searching through the commit history for you. You can also go back through the a file's history in
the web portal as well for a different approach to determining who made a change and when. Go into the Code
Explorer for your repository and branch, then click on the file of interest. Azure Repos will show a complete
commit history for that file on the current branch.
I've made changes to some files and now I can't checkout to a different branch or rebase my work.
Checking out to a different branch in Git will affect the state of files on your filesystem as Git uses the commit
history to make sure you are working with the files that represent the state of your branch. If you attempt to
change branches while you have uncommitted changes, those changes would be overwritten during the checkout.
Git doesn't want you to accidentally lose your changes, so it prevents the checkout from happening. You can
resolve this by:
Abandoning the changes and return to the most recent commit. See undoing changes in Git for instructions on
how to roll back to the most recent commit.
Committing the changes. See saving your work in Git with commits.
Stashing your current work, saving the changes for later and cleaning up the workspace to the last commit.
I've done some work but need to swap to something else. How can I save my work for later without committing
the changes?
The problem with these options is that sometimes you want to keep the changes, but not commit them because
they are not at a point where you are comfortable doing so. Git provides a compact way of doing this using stash .
Stash takes the current staged and unstaged changes in your branch and saves the work, then returns your branch
back to the state of the last commit. You can change to the other branch, do your work, then when you return to
this branch run stash apply to restore the changes.
Once you run git stash apply the most recently stashed changes will be applied to your current branch. If there is
a conflict applying the stashed changes, stash will restore the changes for the files that do not conflict and create
conflict markers in the files that do conflict for you to resolve. You should merge the changes manually in this case.
Once you are done with the stash, delete it with git stash drop . This will remove the last set of stashed changes.
A final note about stash is that you can have multiple stashes, but doing so requires more manual manipulation as
you have to explicitly apply and drop stashes. You can read more about this from in the Git Stash documentation.
How can I change the default editor that is used when working with Git command line tools?
By default, command line Git will use a command-line editor when asking for commit messages, performing
rebases, and other work that requires additional information to complete. The default editor is configured using
git config :
Note that Git For Windows makes it very easy to set notepad as the editor:
Which will configure Windows' Notepad to edit Git information as needed and properly pass through the text
from Git to Notepad. You can also specify
To keep the text columns in the commit messages to the preferred 72 and line wrap after hitting that character limit
on a line.
How can I change the username and email displayed in my commits?
Git puts a user name and email address information inside each commit, and Azure Repos uses this information
when viewing commits and when working with pull requests. If you are working on the command line, you can
update the name and email information displayed using the git config command:
> git config --global user.email "frank@fabrikam.com"
> git config --global user.name "Francis Totten"
Note that the --global option will set the email and name included in commits for all Git repositories on this
system. If you want to change the settings for a single repository, you must change to the directory where the Git
repository is located and run the above commands without the --global flag.
You can also change the name and email settings from Visual Studio. In Team Explorer, choose Settings and under
Git, click the Global Settings or Repository Settings link.
Commit history
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 Update 1
For each commit, you can view the following key elements:
Author details - You can view the author and committer of each commit along with the associated time.
Complete commit message - If the commit message is too long, you can click on the down-arrow to expand
the commit message to view the entire commit message.
Copy commit SHA - You can copy the 40 character commit SHA by clicking on the Copy full SHA to
clipboard button. You can click on a commit ID or commit message to open the commit details page.
Build and PR information - You can view the pull request that brought this commit to the branch selected
on the page, and view the build status of the current commit.
You can select a repository from the repository picker to view the history of a particular repository.
You can select a particular branch or tag from the branch picker to view associated history.
You can further filter the results by selecting a particular file from the code explorer.
You can also find a file or folder to view its history. In the following example, when you type "get", you see
results of all files and folders in the repository that contain the word src.
History result filtering
You can filter the results using the following advanced filtering modes: simple history, first parent, full history,
and full history with simplified merges. For more information, see advanced git history options.
You can also filter commits by authors. You will see authors of most recent commits in the author filter drop down.
In case you are not able to find an author in the drop down, then you can type the author name or email address
and search for all commits by that author.
In case you want to view commits that were authored between any two dates, you can use the From date and To
date filter to scope down the list of commits.
Commit search
You can also search for a commit using its Commit ID. You can search for all commits starting with a commit ID. If
you enter the 40 character Commit ID then you will be redirected directly to the commit details page.
Commit for file renames
In case a file or folder is renamed, you will see all commits until the file or folder got renamed. You will also see a
link suggesting Show rename history.
When you click on Show rename history you can view all the commits of the file or folder before the rename.
Commit details
5/31/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 Update 1
Associated pull requests - Once you navigate from the commit history to the commit details, the context of
the branch from the commit history page is retained. In the following example you can see that commit #33
brought this commit to the master branch. You can also view all the associated pull requests for this commit,
which are all the pull requests that brought this commit to one branch or another.
Associated work items - You can also view all the work items associated with this commit in the work items
dropdown.
Build status - You can also review the build status associated with the commit.
Cherry pick - Click on Cherry-pick to cherry pick a commit and port the changes to another branch.
Revert - Click on Revert to revert the changes of a commit . A topic branch is created with the reverted
changes and then you will be prompted to create a pull request to the target branch.
New branch - Click on New branch to create a new branch from a commit.
What are the changes included in the commit?
The source explorer allows you to select a file or a folder to view changes associated with a commit.
Diff to parent - Click on Diff on parent1 in the Source Explorer pane to view the difference between the
current commit and its parent commit.
The file explorer view provides all the capabilities that we get in the file explorer view i.e. you can
browse files in a side by side or inline diff view
use the navigation keys to browse the next set of changes
preview the files
compare file diff for previous commits
Default Git repository and branch permissions
3/5/2019 • 3 minutes to read • Edit Online
Azure DevOps Services | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | TFS 2013
After you've been added as a team member, you are a member of the Contributors group. This membership allows
you to contribute to a Git repository. The most common built-in groups include Readers, Contributors, and Project
Administrators. These groups are assigned the default permissions for contributing to a branch or repository.
From the project admin content, on the Version Control page, you can set permissions on a repository.
From the Code > Branches page, you can set permissions for a specific branch and set branch policies.
Set permissions across all Git repositories by making changes to the top-level Git repositories entry. Individual
repositories inherit permissions from the top-level Git Repositories entry. Branches inherit a subset of
permissions from assignments made at the repository level. For branch permissions and policies, see Set branch
permissions and Improve code quality with branch policies.
Set permissions across all Git repositories by making changes to the top-level Git repositories entry. Individual
repositories inherit permissions from the top-level Git Repositories entry. Branches inherit a subset of
permissions from assignments made at the repository level. For branch permissions and policies, see Set branch
permissions and Improve code quality with branch policies.
By default, the project-level Readers groups have read-only permissions.
Tag Creation: Can push tags to the repository, and can also edit or
remove tags if they have the Force permission.
The Project Collection Build Service can read from all repositories by default. Any pipeline which runs with project
collection scope can potentially read any repository in the organization/collection. You can remove this permission
for a repository: set "Read" to "Deny" for the Project Collection Build Service.
Related articles
Set repository permissions for Git or TFVC
Set permissions for a specific branch and set branch policies
Git permissions prior to TFS 2017 Update 1
Default permissions and access
Permissions and groups reference
Git limits
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos
We impose a few resource limits on Git repositories in Azure Repos. Our goal is to ensure reliability and availability
for all customers. Also, by keeping the amount of data and number of pushes reasonable, you can expect to have a
better overall experience with Git.
Git participates in rate limiting along with the rest of Azure DevOps. In addition, we impose limits on the total size
of repositories and pushes.
Repository size
Repositories should generally be no larger than 10GB. You can run git count-objects -vH in a command prompt,
and look for the entry called "size-pack" to determine how large your repository is:
count: 482
size: 551.67 KiB
in-pack: 100365
packs: 25
size-pack: 642.76 MiB <-- size of repository
prune-packable: 83
garbage: 0
size-garbage: 0 bytes
In uncommon circumstances, repositories may be larger than 10GB. For instance, the Windows repository is at
least 300GB. For that reason, we do not have a hard block in place. If your repository grows beyond 10GB,
consider using Git-LFS, GVFS, or Azure Artifacts to refactor your development artifacts.
Push size
Very large pushes use up a lot of resources, blocking or slowing other parts of the service. Such pushes often don't
map to normal software development activities. Someone may have inadvertently checked in build outputs or a
VM image, for example. For these reasons and more, pushes are limited to 5GB at a time.
There's one exception where large pushes are normal. When you migrate a repository from another service into
Azure Repos, it comes in as a single push. We don't intend to block imports, even of very large repositories. If the
repository is more than 5GB, then you must use the web to Import the repository instead of the command line.
Whether your software project is large or small, using version control as soon as possible is a good idea. Version control systems
are software that help you track changes you make in your code over time. As you edit your code, you tell the version control
system to take a snapshot of your files. The version control system saves that snapshot permanently so you can recall it later if
you need it.
Azure DevOps Services and TFS provide two models of version control: Git, which is distributed version control, and Team
Foundation Version Control (TFVC ), which is centralized version control. This article provides an overview and a starting point for
using Team Foundation Version Control. If you're deciding which type of Azure DevOps Services/TFS version control to use, see
Choosing the right version control for your project.
5-Minute Quickstarts
Get started by creating a project, configuring your workspace, and reviewing and sharing your code. You can use any one of these
clients or IDEs:
Visual Studio
Xcode
Eclipse
Step-by-Step Tutorials
Learn the basics of working in TFVC with the following tutorial which shows a day in the life of a devops developer using Visual
Studio and TFVC.
Day in the life of a devops developer: suspend work, fix a bug, and conduct a code review
Visual Studio: Review Code
Resources
What is version control?
Migrate from TFVC to Git
Learn more about TFVC
Use Team Foundation Version Control
5/10/2019 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Whether your software project is large or small, using version control as soon as possible is a good idea. Version
control systems are software that help you track changes you make in your code over time. As you edit your code,
you tell the version control system to take a snapshot of your files. The version control system saves that snapshot
permanently so you can recall it later if you need it.
Azure DevOps Services and TFS provide two models of version control: Git, which is distributed version control,
and Team Foundation Version Control (TFVC ), which is centralized version control. This article provides an
overview and a starting point for using Team Foundation Version Control. If you're deciding which type of Azure
DevOps Services/TFS version control to use, see Choosing the right version control for your project.
Related Sections
Build and test the app in your automated build system
Install a bit of software to create a build server, and then fill in a few fields to create a Continuous
integration (CI) or nightly build process that enables you to leverage the power, convenience, scalability,
and reliability of an automated build system to build your app.
Naming restrictions in Team Foundation
Provides information about naming syntax, conventions, and limitations.
Use Team Foundation version control commands
Learn about TFVC permissions
We are not currently republishing the following sections. However, you can read the Visual Studio 2010 version of
this guidance.
Administering Team Foundation Version Control
Develop and share your code in TFVC using Visual
Studio
8/7/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Whether your software project is large, small, or brand new, in most cases you'll be better off if you use version
control as early as possible. Here, we'll show you how to get started with Team Foundation Version Control
(TFVC ), a centralized system. If you want to work in a distributed system, you can instead use Git with Azure
Repos.
Is your code in another place? Learn how to migrate it here.
Now that you've added your app, you can skip down to snapshot your code.
Your whole team can work on the code now. All your changes are tracked in version control.
2. Compare the modified file with the latest version in source control.
You can also check in from the code window, or the team explorer.
4. If you're working on a task or fixing a bug that's tracked as a work item, add that work item to your pending
changes. Source control will resolve the bug or close the task, and it'll link the changeset to the work item.
5. Add a comment and check in.
Next steps
Get your code reviewed
Share your code in TFVC using Eclipse
5/31/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Share your code with your team with Azure DevOps Services and Eclipse.
Before you start:
1. If you don't have an organization, create it first.
2. If you have not yet connected to a project in your organization, do that now.
If your project uses TFVC in your Azure DevOps organization, read on. However, if your project uses Git in your
Azure DevOps organization,then read Share your code in Git using Eclipse
Next steps
Build your Eclipse projects
Share your code in TFVC using Xcode
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Share your Xcode projects using a TFVC repository by using the Git-tf command line tool to push your changes
from the local Git repository to TFVC.
export JAVA_HOME=/Library/Java/Home
export PATH=$PATH:$JAVA_HOME/bin:/git_tf
pushd /ws/FabrikamFiber
4. To share your Git repository in Azure Repos, configure the connection and check in your code. You'll be
prompted for credentials.
Or, if your team's code is already in Azure Repos, you can clone a local repository using Git-tf.
5. If you don't want to be prompted for credentials every time you run Git-tf, you can store your credentials in
your Git configuration.
git commit -a
git tf checkin
If you've committed multiple changes locally, you'll still get just one changeset in Azure Repos.
2. Resolve a bug or close a task when you check in by providing the work item ID with the resolve flag.
git tf checkin --resolve=21972
The changeset and the work item are linked, and you'll be able to see which bugs are resolved and which
tasks were completed in the build reports.
3. You can make sure you're working with your team's latest code by pulling from Azure Repos.
git tf pull
Additional information
Should I use Git or TFVC for my project?
If my project uses Git Version control, can I still share my Xcode projects in Azure DevOps Services?
Should I use Git or TFVC for my project?
That depends on a number of factors, like the size of your codebase and the size and distribution of your team.
Learn which version control (Git or Team Foundation Version Control) works best for you.
If my project uses Git Version control, can I still share my Xcode projects in Azure DevOps Services?
Yes, see Share your code in Git using Xcode.
Next steps
Choosing the right version control for your project
Day in the life of a devops developer: suspend work,
fix a bug, and conduct a code review
5/10/2019 • 10 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
A powerful one-click way to switch your working context from one thread of work to another is available in Visual
Studio Premium and Visual Studio Ultimate with Team Foundation Server. Also, team members can easily
exchange messages about proposed changes to the code. This topic illustrates these features, continuing a tutorial
that follows members of a fictitious agile team for a day.
Peter has been busy writing some code to fulfill a backlog item task. However, his colleagues have found a bug
that is blocking them, and he wants to fix it immediately. He suspends the work that he's doing and fixes the bug.
He asks Julia to review the fix and, after the review, checks in the fix and resumes work on his original task.
Note: The My Work and Code Review features that Peter uses are available only in Visual Studio Premium
and Visual Studio Ultimate.
Note: Your working context is linked to the work items that show as In Progress on the My Work page. By
using Suspend and Resume, you can quickly switch between different tasks. Your open solutions and files,
code changes, and Visual Studio layout are all switched together.
Tip: The currently In Progress work items link to your current code changes and Visual Studio state. To allow
Visual Studio to help you organize your work, make sure that the appropriate items are in the In Progress
state when you switch from one task to another.
From the IntelliTrace log, Peter sees that sometimes the method returns false because the parameters differ by an
extremely small amount. Peter knows that rounding errors of this kind are unavoidable in floating point
arithmetic, and that it is bad practice to test floating point numbers for equality.
Tip: Notice that the team members use the tests as a focus for discussion. If the tests are correct and
sufficient, the code will be also. Unlike the code, each test represents a separate case. For this reason, the tests
are often easier to discuss than the code.
Tip: To fix a bug, follow the same practice as in code development. Write a test that fails and then make the
test pass. Check in the code and the tests only when the tests pass.
Peter now turns his attention to the test case in which the bug was discovered. The steps to reproduce the bug are
clearly described in the test case work item. He follows the steps and discovers that the invoices are correctly
listed.
In Team Explorer, on the My Work page, find the Suspended & Shelved Work list. Open the shortcut
menu for the item. You have two choices:
If you want to resume the suspended work and automatically suspend any pending changes in your
workspace, choose Resume.
If you want to merge the suspended work with pending changes already in your workspace, choose
Merge with In Progress.
When you resume your work
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Before you check in your code, you can use Visual Studio to ask someone else from your team to review it. Your
request will show up in his team explorer, in the my work page.
To ask for a code review, make sure you have shared your code in TFVC.
(Are you using Git to share your code? If so, then use a pull request.)
2. He requests a review.
You can get email alerts for code reviews, too. If you aren't getting them, you can sign up in the team
explorer settings page.
2. His changes are unshelved and the windows he had opened are restored, so he can incorporate the review
feedback.
Next steps
Create your backlog
Choosing the right version control for your project
5/31/2019 • 9 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Whether your software project is large or small, using version control as soon as possible is a good idea. Azure
Repos supports two types of version control: Git and Team Foundation Version Control (TFVC ).
NOTE
Git in Visual Studio, Azure DevOps Services, and TFS is standard Git. You can use Visual Studio with third-party Git services,
and you can also use third-party Git clients with TFS.
Conflict resolution You might have to resolve conflicts You might have to resolve conflicts
when you get, check in, merge, or when you pull or merge. You can
unshelve. You can resolve all types of resolve content conflicts in Visual
conflicts in Visual Studio. Studio or from the command prompt.
Capability TFVC Git
File storage You can check in large binary files. You You can check in small binary files as
might also want to use NuGet in you would regular files. When working
combination or as an alternative. with large binary files, use Git-LFS to
store your large binary files in Azure
Repos.
History File history is not replicated on the File history is replicated on the client
client dev machine and so can be dev machine and can be viewed even
viewed only when you're connected to when not connected to the server. You
the server. You can view history in can view history in Visual Studio and on
Visual Studio and on the web portal. the web portal. You can annotate files
You can annotate files to see who to see who changed a line, and when
changed a line, and when they changed they changed it.
it.
Tag your files You can apply labels to a version of one You can apply tags from the command
or more files from either Visual Studio prompt to individual commits. View
or the command prompt. Each file can tags in the Visual Studio history
have label applied to a different version. window.
Roll back changes You can roll back one or more You can revert a commit.
changesets
Scale You can work on small or very large You can quickly begin small projects.
scale projects using local workspaces. You can scale up to very large projects,
Supports massive scale (millions of files but you have to plan ahead to
per branch and large binary files) modularize your codebase. You can
projects using server workspaces. create multiple repositories in a project.
Server
Server Azure DevOps Services, TFS Azure DevOps Services, TFS and Git
third-party services
Alerts Team members can receive email alerts Team members can receive email alerts
when check-ins occur. when commits are pushed to the
server.
Auditability Because your team checks in all their You can identify which user pushed a
work into a centralized system, you can commit. (Anyone can claim any identity
identify which user checked in a as the author or committer.) You can
changeset and use compare to see identify when changes were made what
what they changed. Looking at a file, was changed using history, compare,
you can annotate it to identify who and annotate.
changed a block of code, and when
they did it.
Builds (automated by TFBuild) You can use all TFBuild capabilities to You can use most TFBuild capabilities to
build any combination of content you build one project at a time, and one or
want within the project collection. more repositories at a time.
Capability TFVC Git
Code reviews Yes; see Day in the life of an devops Yes; see Conduct a pull request. For
Developer: Suspend work, fix a bug, more lightweight discussions, you can
and conduct a code review. For more also comment on and send email about
lightweight discussions, you can also a commit from the web portal.
comment on and send email about a
changeset from the web portal.
Files Each project contains all files under Each project can contain one or
a single root path (for example: more Git repositories and each Git
$/FabrikamTFVC). You can apply repository can contain one or more
permissions at the file level. You can branches. The most granular
lock files. permissions you can apply are to a
repository or a branch. Files cannot
You can browse your files on the be locked.
web portal and using Source
Control Explorer in Visual Studio. You can browse your files on the
web portal.
Your project exists on only one
server. You can push commits to multiple
remote repositories (for example to
both your project repository and to
your web site hosted on Windows
Azure.
Quality gates You can use CI builds, gated check-in You can use CI builds and gated check-
builds and check-in policies. in builds through branch policies.
Client
Client software Visual Studio, Eclipse (with Team Visual Studio, Eclipse, and other third-
Explorer Everywhere) party tools
Files You can browse your files using Source You can browse your files using
Control Explorer in Visual Studio, or Windows File Explorer or the command
using Windows File Explorer or the prompt.
command prompt.
Manage work on your dev machine Pending changes and my work pages. Changes, commits, and branches pages.
Suspend your work You can suspend from my work page or You can create a branch from (from
shelve your changes. Visual Studio or the command prompt)
or stash (from the command prompt)
Capability TFVC Git
User interface Visual Studio: Offers all Visual Studio: Offers many
commonly used features and commonly used features.
many advanced features. Features for some common
TFS web portal: Can browse, tasks are not yet available.
comment, annotate, and see TFS web portal: Can browse,
history of the codebase. comment, annotate, and see
TF Command prompt: history of the codebase.
Installed with Visual Studio. Third-party command
Used for advanced, prompt: You can install it from
administrative, and other less Visual Studio. Used for some
common tasks. common and many less
common tasks.
Visual Studio compatibility You can use all supported previous Git is built in with Visual Studio
versions of Visual Studio. 2017, 2015, and 2013.
You can also use Visual Studio
2012 Update 4 (you must also
install Visual Studio Tools for Git).
Web portal You can browse your codebase You can browse your codebase, view
(including branches), view history, history, compare branches, annotate
annotate and comment on changesets and comment on commits, and perform
and shelvesets, and perform other tasks other tasks such as ad hoc
such as ad hoc downloading of selected downloading of selected parts of your
parts of your codebase as a .zip file. codebase as a .zip file.
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 Update 1
In Team Foundation Server 2015 Update 1, a project administrator can add a Git repo to a project created with
Team Foundation Version Control (TFVC ). You can also add a TFVC repo to a project created with Git. This allows
you to adopt a new version control system while preserving all the data in your project.
Do you plan to adopt Git, are familiar with TFVC actions, and wondering how they map to Git? Both are powerful
and mature source control systems. However, mapping common actions you have grown accustomed to in the one
to the other can be a confusing experience.
This article will not delve deep into the Git commands, as they are well documented in the product documentation,
but show examples to help you make the right decisions, while moving through a typical create -> clone -> branch
-> change -> commit -> push workflow.
Once the repo is created, you are presented with step-by-step instructions to quickly get started.
Click on the `Create a ReadMe file' at the end of the instruction page, to give the repo context and to create some
history.
You only need to clone once per repo, but like TFVC workspaces, you can have multiple clones to isolate in-
progress work. However, branching is typically a better way to isolate changes.
Create a branch
With Git, you are always working in a branch and by default in the "master" branch. You are recommended to
create multiple local branches. It's a process that takes seconds and allows you to seamlessly context switch
between branches and work in isolation. Unlike TFVC branches, which are paths scoped, Git branches are
repository scoped. They are lightweight, can be local only, or shared with others when you are ready to share your
changes.
Consider branching if you need to work in isolation, need to suspend your work, focus on new features, or if you
are planning to conduct a Git pull request.
As a TFVC user, repeat a few times:
Branching is recommended!
Git branching is inexpensive, fast, and powerful!
Git encourages you to use local branches.
Publish local branches to your centralized repository as needed.
Always verify your branch context before making changes.
Name the branch using a common convention such as users/alias/branchname for example:
users/doris/newfeature
Create and switch to a local topic branch, named francis/demo -feature. It is good practice to run a git status first,
to verify that you are on the right branch to start with.
Command Line
Visual Studio
or
Using the pre-baked sample, you will have 13 new files that have been included and staged in the local repository.
git status
Checkin changes and commit locally
In TFVC, you share your changes with a Check In, which sends your pending changes to the server. The Git process
is a bit different. First, you commit to the local repository, creating a commit object (like a changeset), then you
push to send those changes with the server.
You commit the changes to your local repository using git commit , which feels like doing a
Checkin Pending Changes in TFVC. A key difference is that the git commit commits your changes to the local, not
the remote repository.
Command Line
Visual Studio
git commit
To synchronize further updates in your local with the remote repository, you need to push your changes using
git push . The recommended practice using the git command or the Visual Studio IDE is to:
View history
To see the commit, you just created you can review the local history.
Command Line
Visual Studio
For a compact history, use:
git log --oneline
git log
As shown above, git log lists the author, email, date written, and the commit SHA-1 checksum. As a TFVC user
you may want to use the --stat option to include more information, such as file name and change statistics.
You can also view the history of the centralized repository using the Azure DevOps Services web portal.
In the Azure DevOps Services web portal, choose CODE > History or CODE > Explorer > History
At this point, you have successfully explored the create -> clone -> branch -> change -> commit -> push
workflow, based on common TFVC actions.
You also have the option of issuing a pull request, to publish and stage your changes on the server/remote repo at
this point.
Other actions
Switch branches
When working with Git, you do not change branches by switching to separate folders and locations on your
machine. You change the context by doing a checkout , making the entire working directory match the selected
branch or commit. Fast and simple!
Command line
If you forgot what branches you have in your local repository, use git branch to list the default and known
branches.
Keep in mind which branch you are working on! When you work with multiple branches in Git, you switch
branches in place in the same working directory. Switching between branches is a fast operation, and making sure
you are on the right branch at all times is good practice.
Get latest version
There are lots of reasons to want to get updates. For example, when you need to switch context to another project,
refresh your development machine with the latest version of the codebase.
Command line
git pull
or
git fetch
followed by
Always get the latest version and resolve merge conflicts locally.
Undo local changes
There may be a valid reason to revert all revisions you made in your local repository and reset your working
environment to the latest version from the remote repository.
Command line
followed by
followed by
The scenario is synonymous to doing a Get > Latest Version with the
Overwrite writable files that are not checked out and
Overwrite all files if the local version matches the specified version options in TFVC.
Alternatively you can manually delete your local repo - after making a validated copy off course - and then clone
the repository again.
There are a lot more actions and options available to Git users. Here are some useful reference sites for further
reading:
Git commands covered herein, refer to git documentation
Think like (a) Git, a Guide for the Perplexed.
How to undo (almost) anything with Git, by Joshua Wehner
Q&A
What about sync?
"Does the Visual Studio IDE Commit and Sync not magically do all this?", you may be asking yourself.
With magic comes responsibility! Many users dislike the sync as it can sometimes mess up your local history and
add a merge commit on top of your current commit. Once you are in a bad state, you have to revert to the
command line as there is currently no reset support in the IDE.
Authors: Jesse Houwing, Martin Hinshelwood, Mike Fourie, and Willy Schaub from the ALM | DevOps Rangers.
Connect with them here.
(c) 2015 Microsoft Corporation. All rights reserved. This document is provided "as-is." Information and views
expressed in this document, including URL and other Internet Web site references, may change without notice. You
bear the risk of using it.
This document does not provide you with any legal rights to any intellectual property in any Microsoft product.
You may copy and use this document for your internal, reference purposes.
Explore the feature isolation strategy using Team
Foundation Version Control (TFVC)
2/21/2019 • 4 minutes to read • Edit Online
Are you planning to implement Team Foundation Version Control's feature isolation strategy in Team Foundation
Server (TFS ) or Azure DevOps Services? You probably have a few questions, such as:
Is it practical with large development teams?
Does it align well with your agile process(es)?
What's the proper lifetime of isolated feature branches?
This article aims to answer those questions, and give you a clear perspective on feature isolation in TFVC. (For
guidance on TFVC branch strategies overall, read Branching Strategies with TFVC.)
NOTE
This article covers TFVC. For Git, refer to adopt a Git branching strategy.
NOTE
The reference to "feature" is not related to the Feature work item type. This strategy can be used with Epic, Feature, Program
Backlog Item, User Story, or whatever work item type you've defined in your process.
It's typical to create one feature branch per feature or bug, but in this strategy, you can create a miscellaneous
feature branch to isolate a couple of low risk features.
Unlike Git branches, which are repository-scoped, TFVC branches are path-scoped and therefore not as
lightweight. To work around this, limit the number of and the lifetime of your TFVC feature branches, and optimize
your workspace using explicit, implicit, cloaked, and non-recursive folder mappings, to improve performance, and
to reduce required disk space on your machine.
TIP
Your workspace should contain only the files you need. Consider creating multiple workspaces to isolate and switch among
multiple feature branches. To avoid confusing yourself, use a consistent naming convention for both your workspace and
feature branch.
This strategy also keeps features from getting out of sync with the parent branch. Remember to FI before you
reverse integrate (RI) your changes back to the parent branch!
TIP
Keep your feature branch short-lived!
Unlike main or other central branches, feature branches have a limited life time. They are scoped to features, bugs, and hot
fixes, which are typically developed within a sprint or iteration. Consider removing your feature branch once your feature has
met your team's definition of done DoD and changes have been merged with the parent branch.
As the number of your feature branches increase, your storage requirements and branch hierarchy visualization
noise increases. With only five feature branches, the diagram is already noisy and rapidly losing its monitoring
qualities. Can you imagine the impact of your team creating hundreds of feature branches?
Similarly, the Source Control Explorer view becomes noisy and impractical as the number of branches increases.
Unless you have a consistent naming convention, finding a specific feature branch among hundreds of feature
branches is challenging.
TIP
Delete your feature branch when you're done!
If no one in your team has destroyed a branch using the destroy command, you'll have the complete history
needed for auditing and migration tools that rely on replaying history.
NOTE
Use the destroy command with caution. It's a permanent delete!
By keeping your branches short-lived and adopting a consistent naming convention, the feature isolation
strategy is effective for small and large teams.
Now that you're using feature isolation, you should explore continuous integration, feature toggles, and other
complementary strategies.
Reference information
Branching Strategies with TFVC (new guidance)
Branching and Merging Guidance (latest copy of classic guidance)
Continuous Integration
Feature Toggles
Team Foundation Version Control (TFVC )
Author: Willy Schaub | Find the origin of this article and connect with the ALM | DevOps Rangers here
(c) 2017 Microsoft Corporation. All rights reserved. This document is provided "as-is." Information and views
expressed in this document, including URL and other Internet Web site references, may change without notice. You
bear the risk of using it.
This document does not provide you with any legal rights to any intellectual property in any Microsoft product.
You may copy and use this document for your internal, reference purposes.
Test Impact for partially mapped TFVC repositories in
TFS/Azure DevOps Services
5/10/2019 • 2 minutes to read • Edit Online
Now, in your build/release pipeline you see Get sources tile under Process as shown in the following example.
Select Get sources and you'll see options on the right blade to partially map your repository.
If you enlist the entire repository, as shown in the previous example, TIA continues to work fine, but if you enlist
partially, as shown in the following example, TIA fails to find the impacted tests.
When a TFVC repository is partially enlisted, TIA fails to find the impacted tests because the collector is able to
collect changes only for the partially enlisted repository on the agent and does not have visibility of the entire path.
When a code change flows in from the server, it provides the entire path, and the matching attempt with the
mapped path fails.
Workaround
To work around this issue, you can map your partial repository to the complete code structure on the server, so that
the full path of the files on your local enlistment match the full server path. To do this, you can specify a Local path
that matches the server path, as shown in the following example.
This ensures that the server path matches the path collected by the collector and impacted tests are correctly listed.
Explore how to manage branching strategies with a
DevOps mindset in Team Foundation Version Control
(TFVC)
5/31/2019 • 4 minutes to read • Edit Online
Are you planning to embrace DevOps using the Team Foundation Version Control (TFVC ) with Team Foundation
Server (TFS ) or Azure DevOps Services? You probably have a few questions, such as:
How do I decide on the right branching strategy?
Is there an effective strategy for DevOps?
How do I support applications with single or multiple versions?
TFVC is a centralized version control system to maintain code and make teams more effective. It provides
collaboration and consistent code sharing, publishing, and review features.
Keep it simple!
By adopting an effective branching strategy, you'll:
Foster a DevOps culture
Promote collaboration flow and increased productivity
Enable teams to spend more time developing and less time managing code
To embrace DevOps, it's important to keep your branch strategy simple and strive for high quality. Some
suggestions:
Start with a simple strategy and evolve as needed
Use consistent naming conventions for branches
features/username/description for work performed by an individual - example, features/sandra/sdk-java
bugfix/username/bugid for work done specific to an engineering bug - example, bugfix/takashi/707
releases/version for planned releases - example, releases/V1.00
Frequently reverse integrate (RI) and merge into your main branch
Encourage consistent code reviews - garbage in, garbage out
Implement a CI/CD pipeline, using:
Gated checkins
Automated testing
Automate your build to trigger with every checkin to the main branch, run automated tests, and if successful,
deploy the release to a development (dev) environment.
When you complete a release cycle, create a release branch. Use the release branch to stabilize the release, and
continue development for your next version in main. Reverse integrate (RI) and merge validated bug fixes with
your main branch frequently, to minimize your overall technical debt.
V1.00 RC_Bld Dev -> QA -> UAT -> Triggered with every checkin
Staging -> Prod to release
When version 2 becomes the Release Candidate, you can update your existing RC build pipeline to point to the
V2.00 branch. It will now build and release just as V1.00 did when it was the current version.
V2.00 RC_Bld Dev -> QA -> UAT -> Triggered with every checkin
Staging -> Prod to release
V1.00 Hotfix_Bld Hotfix -> Staging -> Prod Triggered with every checkin
to hotfix
By using a simple branching strategy and adopting a consistent naming convention, you'll be able to support:
Applications that have one or more supported releases
Continuous development of new features
Continuous delivery of value to your users
Reference information
Continuous Integration
Interview with Abel Wang and Steve St Jean
Team Foundation Version Control (TFVC )
What is DevOps - Definition
What is DevOps - Sticker
Authors: Sergio A Romero | Find the origin of this article and connect with the ALM | DevOps Rangers here
(c) 2017 Microsoft Corporation. All rights reserved. This document is provided "as-is." Information and views
expressed in this document, including URL and other Internet Web site references, may change without notice. You
bear the risk of using it.
This document does not provide you with any legal rights to any intellectual property in any Microsoft product.
You may copy and use this document for your internal, reference purposes.
Use branches to isolate risk in Team Foundation
Version Control
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Consider some challenges team members typically face when they work on a software project that is staffed by
more than five or ten people:
The group has a few (or maybe several) different feature teams, each working on a set of functionality that
is reasonably discrete. But each team also depends on functionality built by other teams. You need to
isolate the risk of the changes introduced by the work done in each of these teams, and yet eventually, you
need to merge all their efforts together into one product.
The test team needs a stable version of the code to test, and yet simultaneously, the developers need to
continue moving forward with new features that will occasionally destabilize the product.
The software has two previous versions and one current version in progress. Even though most of the
development effort is invested in the current version, the previous versions must still be supported with
occasional releases of service packs, critical fixes and security patches, and other changes.
In This Section
This section describes the branching and merging tools provided by Team Foundation version control to enable
you to meet these and other challenges faced by groups of people who collaborate on a software project.
Branch folders and files
Explains the procedure used to create branches by using Team Foundation version control.
Branch strategically
Your team can create and use branches in version control to optimize your application development strategy.
Merge folders and files
Explains the procedure used to merge branches by using Team Foundation version control.
View where and when changesets have been merged
Explains how to view and work with actionable diagrams that illustrate where and when merges have occurred.
View the branch hierarchy of a project
Explains how to view and work with an interactive diagram that illustrates the branch hierarchy of your project.
Associate a file type with a merge tool
Describes the steps used to specify the file type extensions associated with merging.
Reference
Use Team Foundation version control commands
Related Sections
Compare folders and files
Explains how to compare or diff files, folders, and shelvesets.
Resolve Team Foundation Version Control conflicts
Lists topics about how to resolve merges, check in procedures, and get retrieve conflicts.
See Also
Other Resources
Branch strategically
Visual Studio TFS Branching Guide
Branch folders and files
5/10/2019 • 7 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
You can use branches to accomplish the following goals:
Manage concurrent work by multiple teams on the same codebase
Isolate risks that are introduced by different sets of changes to the codebase
Take snapshots and then support subsequent isolated changes (for example, to create a release branch)
For example, the following illustration shows how the DinnerNow company developed a branch structure to meet
its business needs.
The following screenshot shows the DinnerNow branch structure in the Hierarchy window.
Feature Team A and Feature Team B each do their work in separate branches. When the teams are ready to
integrate their work, they merge their branches into the Dev branch. When the builds from the Dev branch are
stable and ready to test, the teams merge the Dev branch into the Test branch.
As each version is released, the Main branch is branched into a new version branch, such as the Version1 branch
and the Version2 branch. By following this strategy, the company can enhance or fix each past version of the
product separately if necessary.
You can perform a branching operation by using either Source Control Explorer, as this topic demonstrates, or
the Branch command at a command prompt. For more information, see Branch Command.
Tip:
Branching is an important and powerful technique for creating a parallel set of versions of your files.
However, using branches can add complexity and cost to your project. For example, when you merge two
branches, you may have to resolve conflicts.
Before you create a branch, you should consider whether you can better meet your needs by applying a label.
By applying a label, you can quickly and easily take a snapshot of the state of your files so that you can then
later retrieve or build the files in that state. For more information, see Use labels to take a snapshot of your
files.
Convert a Folder to a Branch
The release of Visual Studio Team Foundation Server 2010 began a distinction between branches and folders.
The following illustration shows the top-level of the DinnerNow folder structure:
DinnerNow folder structure in Source Control Explorer
As the illustration shows, you can still use folders to organize branches within a project's version control
hierarchy. However, folders and branches have a different appearance and different capabilities. When you right-
click a folder or branch and click Properties, you display different information and different functionality.
When you perform branch operations, branches have important advantages over folders. Branches support
version control features that provide extra visibility into your branch structure and into where your changesets
have merged. (For more information, see the links in the See Also section later in this topic.)
Although you can still branch and merge among folders, the best practice for your team is to branch and merge
only among branches. The following procedure explains how to convert a folder to a branch.
Required Permissions
To perform the following procedure, your Manage branch permission must be set to Allow. For more
information, see Permissions and groups reference.
To convert a folder to a branch
1. In Source Control Explorer, make sure that the folder that you want to convert exists on the server.
2. If the pending addition icon ( ) appears next to the folder, right-click the folder, and then clickCheck In
Pending Changes.
3. Right-click the folder that you want to convert, point to Branching and Merging, and then click Convert
to Branch.
The Convert Folder to Branch dialog box appears.
IMPORTANT
If you are converting a folder that you have already branched, you should probably select the Recursively
perform this conversion for all branched child folders check box. This option also converts to branches all
folders that were branched from this one folder.
4. (Optional) In the Owner field, type the name of the person who owns this branch.
NOTE
The Owner field is for information only. Being named in the Owner field grants no additional permissions.
5. (Optional) In the Description field, type information that you think would be helpful to other team
members who must use this branch or understand its purpose.
6. Click Convert.
IMPORTANT
You cannot nest branches; therefore, you cannot convert any folder to a branch if it either contains a branch or is contained
by a branch. For example, the following illustration shows how neither the parent nor the child of the FeatureTeamA
branch can be converted to a branch.
After you have converted a folder to a branch, you can convert it back to a folder if your team decides to change
your branch structure.
To convert a branch to a folder
1. In Source Control Explorer, click the branch that you want to convert.
2. On the File menu, point to Source Control, point to Branching and Merging, and then click Convert to
Folder.
3. When the Convert Branch Back To Folder message appears, click Yes.
Branch a branch
After you have converted a folder to a branch, you can then create other branches from that branch. The
following procedure shows how you can use the graphical user interface of Visual Studio to branch a branch. (For
information about how to perform this task at the command prompt, see Branch Command.)
Required Permissions
To perform this procedure, your Manage branch permission must be set to Allow for the paths to the source
and target branches. Your Merge permission for the path of target branch must set to Allow. For more
information, see Permissions and groups reference.
To branch a branch
1. In Source Control Explorer, right-click the branch that you want to branch, point to Branching and
Merging, and then click Branch.
The Branch from dialog box appears.
2. In the Target Branch Name box, specify the path of the new branch.
3. (Optional) In the Branch from version section, click one of the following options in the By list:
If you click Latest Version, the branch is created for the most recent version in version control.
If you click Changeset, you can specify the number of the changeset in the Changeset box. As an
alternative, click the ellipses (...) to open the Find Changesets dialog box.
For more information, see Find and view changesets.
If you click Date, you can specify a date in the Date box.
4. Click Branch.
The branch is created and appears in Source Control Explorer.
NOTE
Unlike most version control operations, this operation does not generate a pending change. Rather, the operation is
completed immediately and you cannot undo it.
NOTE
A Browse For Folder window appears if you selected the Create local working copies for the new branch
check box and the local folder that you specified is not mapped in the current workspace. Browse for a folder or click
Make New Folder, specify a folder to synchronize to the version-controlled items, and then click OK.
See Also
Other Resources
Use Source Control Explorer to manage files under version control
View where and when changesets have been merged
View the branch hierarchy of a project
Branch Command
Branches Command
Branch strategically
Visual Studio TFS Branching Guide
Learn about branching strategies for Team
Foundation Version Control (TFVC) and how to select
an effective strategy
5/10/2019 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Do you plan to adopt Team Foundation Version Control (TFVC ) with Team Foundation Server (TFS ) or Azure
DevOps Services? Are you wondering how to best use branches? This article will not delve deep into branching
features, as they are well documented in the product documentation and guidance, but will explore a few common
branching strategies to help you make the right decision.
Unlike Git branches, which are repository scoped, TFVC branches are path scoped and not as lightweight. Set your
bar for creating branches high and only branch when you have a need for code or release isolation.
Main Only
The Main Only strategy can be folder-based or with the main folder converted to a Branch, to enable additional
visibility features. You commit your changes to the main branch and optionally indicate development and release
milestones with labels.
RISK: The mutability and lack of history with TFVC labels can add risk of change control.
Start with the main only branching strategy, branch strategically and adopt other strategies to evolve into more
complex strategies as needed.
Development isolation
When you need to maintain and protect a stable main branch, you can branch one or more dev branches from
main. It enables isolation and concurrent development. Work can be isolated in development branches by feature,
organization, or temporary collaboration.
It's possible that there are changes in the main branch. Always forward integrate (FI) main to the dev branch and
resolve merge conflicts. Then reverse integrate (RI) changes back to main. Maintain the same quality bar across
branches. Build and run build verification tests (BVTs) on dev the same way you are doing on main.
NOTE: With this strategy, teams are likely to keep the dev branch around forever, potentially building a large
merge ticket history.
Feature isolation
Feature isolation is a special derivation of the development isolation, allowing you to branch one or more feature
branches from main, as shown, or from your dev branches.
When you need to work on a particular feature, it might be a good idea to create a feature branch.
Keep the lifetime of feature work and the associated feature branch short-lived. Forward integrate (FI) changes
from the parent branch frequently. Reverse integrate (RI) back to the parent only when some agreed team criteria,
for example definition of done, is met. Rollback of features on main can be costly and may reset testing.
Release isolation
Release isolation introduces one or more release branches from main. The strategy allows concurrent release
management, multiple and parallel releases, and codebase snapshots at release time.
When the release is ready to be locked down, it's time to create a new branch for the release.
Never forward integrate (FI) from main. Lock release branches using access permissions, to prevent unintended
modifications to a release. Patches and hot fixes made to the release branch can be reverse integrated (RI) back to
the main branch.
NOTE: None of the branching scenarios are immutable, which is why you notice emergency hotfixes
performed on release branches. Evolve each strategy to match your requirements, without losing sight of
complexity and associated cost.
Use this strategy if you need a servicing model for customers to upgrade to the next major release and additional
service packs per release.
Like the release isolation, the servicing isolation and release branches are created when the release is ready to be
locked down. Never forward integrate from main to servicing, or from servicing to release. Lock the release
branch to prevent modifications. Future servicing changes can be done on the servicing branch.
Create new servicing and release branches for subsequent releases if you require that level of isolation.
At this point, you have successfully explored a few of the common TFVC branching scenarios. You can evolve them,
or investigate other strategies such as feature toggling, toggling features on and off to determine whether a feature
is available at run time.
Q&A
Why should branches be short-lived?
By keeping branches short-lived, merge conflicts are kept to as few as possible.
Why only branch if necessary?
To embrace DevOps, you need to rely on automation of build, test, and deployment. Change is continuous,
frequent, and merge operations more challenging as merge conflicts often require manual intervention. It is
therefore recommended to avoid branching and rely on other strategies, such as feature toggling.
Why remove branches?
Your goal should be to get changes back into main as soon as possible, to mitigate long-term merge
consequences. Temporary, unused, and abundant branches cause confusion and overhead for the team.
Can a codebase be branched across projects?
Yes. It is not recommended, unless teams must share source and cannot share a common process.
What about the code promotion strategy?
The Code Promotion strategy feels like a relic from the waterfall development era. It is typically with long testing
cycles, and separate development and testing teams. The strategy is no longer recommended. For more
information on this strategy, see the branching guidance.
When merging dev to main branch, why are no changes detected?
You have likely ignored changes in previous merges, for example, using the keep source conflict resolution option.
See merging development branch to main: there were no changes to merge for details.
Are there similarities between TFVC and Git branch strategies?
The TFVC Feature Isolation branching strategy is similar to the Git topic branches.
Authors: Jesse Houwing, Marcus Fernandez, Mike Fourie, and Willy Schaub from the ALM | DevOps Rangers.
You can contact them here.
(c) 2015 Microsoft Corporation. All rights reserved. This document is provided "as-is." Information and views
expressed in this document, including URL and other Internet Web site references, may change without notice. You
bear the risk of using it.
This document does not provide you with any legal rights to any intellectual property in any Microsoft product.
You may copy and use this document for your internal, reference purposes.
Branch strategically
5/10/2019 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Source code is an important asset in your development effort. But it can be a challenge to effectively manage and
evolve source files when multiple developers work concurrently on file updates. You can use a version control
system to store source code in shared repositories, to isolate parallel development efforts, to integrate code
changes, and to recover previous file versions. A key element in version control is branching that enables
simultaneous development. If you branch strategically, you can maintain the order and consistency of multiple
versions of your software.
Team Foundation provides a flexible and reliable version control system. You can use Team Foundation version
control to manage multiple revisions during development of source code, documents, work items, and other
critical information that is worked on by your team.
For more information about how to create and merge code branches, see the following page on the CodePlex
Web site: Team Foundation Server Branching Guide 2.0.
Branching and merging entail the following principles:
1. Each branch must have a defined policy about how to integrate code into this branch. For example, in the
branch structure of the previous illustration, you can assign a team member to own and manage the MAIN
branch. This member is responsible for performing the initial branch operation, reverse integrating changes
from the DEVELOPMENT branch to the MAIN branch, and forward integrating changes from the MAIN
branch to the DEVELOPMENT branch. Forward integration is important when the MAIN branch also
integrates changes from other branches.
2. The MAIN branch must contain code that has passed integration tests so that it is always ready for a
release.
3. The DEVELOPMENT (or work) branch constantly evolves because team members check in changes
periodically.
4. Labels are snapshots of the files in a branch at a specific time.
For more information, see Use labels to take a snapshot of your files.
Team Foundation Build allows you to choose from several types of builds for your branches: manual, continuous,
gated, rolling, and scheduled. We recommend that the MAIN branch has a gated check-in build type. This means
that the DEVELOPMENT branch must pass all requirements for the MAIN branch before you can commit a
reverse integration. The DEVELOPMENT branch should run a continuous build type because your team must
know as soon as possible when a new check-in affects the DEVELOPMENT branch.
How often should your team reverse integrate and forward integrate?
As shown in the following illustration, reverse integration and forward integration should occur at least when you
complete a user story. Although each team might define completeness differently, completion of a user story
generally means that you complete both the functionality and the corresponding unit tests. You can reverse
integrate to the MAIN branch only after unit tests have verified the stability of the DEVELOPMENT branch.
If you have more than one work (DEVELOPMENT) branch, forward integration to all work branches should occur
as soon as any branch integrates into the MAIN branch. Because the MAIN branch is kept stable, forward
integration is safe. Conflicts or failures at the work branches might occur because you cannot guarantee that the
work branches are stable.
It is important that you resolve all conflicts as soon as possible. By using a gated check-in for the MAIN branch,
you help make the reverse integration much easier because quality gates help avoid conflicts or errors in the
MAIN branch. For more information, see Check in to a folder that is controlled by a gated check-in build process.
How does your team manage sources that implement different user
stories?
As the following illustration shows, you can check in changes to a work branch periodically to complete a user
story. You can implement multiple user stories in the same branch at the same time. However, you can reverse
integrate to the MAIN branch only when you complete all the in-progress work. It is recommended that you
group user stories by similar size because you do not want a large user story to block the integration of many
small ones. You can split the two sets of user stories into two branches.
How does the team manage releases from the version control
perspective?
Your team should be able to release code at the end of any sprint. By using Team Foundation Server, you can label
a branch to take a snapshot of the code at a specific point in time. As the following illustration shows, you can
label the MAIN branch for a release. This lets you return the branch to its state at this point.
Because you must implement updates on releases, creating a branch for a release helps your team continue to
work independently on the next sprint without creating conflicts with future releases. The following illustration
shows a branch that contains code for an update and that is reverse integrated into the MAIN branch after a
release at the end of the second sprint.
When you create a branch for a release, you should create that branch from the MAIN branch, which is the most
stable. If you branch for release from a work branch, it can cause integration challenges because the stability of
work branches is not guaranteed.
Merge folders and files
5/31/2019 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
For the various reasons described in Branch folders and files, many software development teams work in a
codebase that is forked into various branches. If you use branches, eventually your team must integrate the work
that has been completed on different branches during certain phases of your project. For example, when you are
ready to test a full version of your software, you will need the changes made on different feature team branches to
be merged together.
The procedures in this topic advise how you can use the graphical user interface of Visual Studio to merge
together changes made in different branches. For information about how to perform merges at the command
prompt, see Merge Command.
Required Permissions
To perform these procedures, you must have the following permissions set:
You must have the Read permission for the item in the source tree and your Check out permission for the
item in the target tree set to Allow.
You must have the Merge permission set for the target path.
If the item in the target tree is being renamed, you must have the Check out permission for both the source
tree and the target tree set to Allow.
If any files affected by the operation are locked, you must have the Lock permission set to Allow. For more
information about permissions, see Permissions and groups reference.
The release of Visual Studio Team Foundation Server 2010 began a distinction between branches and folders. For example, in
the following illustration you can see how branches and folders are displayed with different icons.
While you can still branch and merge among folders, the best practice for your team to follow is to branch and merge only
among branches. For more information, see Branch folders and files.
IMPORTANT
This procedure can be performed only for changesets that affect a branch. For example, in the following illustration you can
view how branches and folders are displayed with different icons.
Tip: If possible, click All changes up to a specific version, as it will reduce the risk of conflicts in
future merges.
If you selected All changes up to a specific version, then the Select the versions of the source
items page appears. Select the version of the items that you want to use.
If you selected Selected changesets, then the **Select changesets to merge into the target branch
**page appears. Select the changeset you want to merge.
Tip: You can press and hold the CONTROL or SHIFT keys and then select multiple items in a
continuous range.
4. Click Next, and then on the Perform the merge operation page, click Finish.
One or more pending changes are generated.
5. (Optional) If you want to check in the pending changes immediately, you can perform these steps:
a. Click the View menu, point to Other Windows, and then click Pending Changes.
b. Use the Pending Changes window to check in the changes. For more information, see Check in your
work to the team's codebase.
See Also
Other Resources
Use branches to isolate risk in Team Foundation Version Control
Merge Command
Merges Command
Resolve Team Foundation Version Control conflicts
Use Source Control Explorer to manage files under version control
View where and when changesets have been merged
5/10/2019 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Branching your code base can be a useful way to isolate concurrent development efforts and to take snapshots.
However, when your team members are working in a branched code base, they may have trouble finding
information about which branches have received a particular set of changes and when those changes were
merged.
For example, your team (Feature Team B ) waits for a fix to a bug in some code on which your code depends. You
receive an e-mail message that states that the bug has been fixed, but you can still reproduce the bug in the builds
that come from your branch.
By opening the Tracking Changeset window, you can determine which branches have and have not received a
set of changes. For example, in the following illustration, the Tracking Changeset window shows how changeset
38 was merged from the Dev branch to a child branch and then baselessly merged to two other branches.
Tracking Changeset window shows branches to which a changeset has merged
Required Permissions
To perform these procedures, your Read permission must be set to Allow for the branches with which you are
working. For more information about permissions, see Permissions and groups reference.
For more information about how to branch, see Branch folders and files.
To view the Tracking Changeset Window from the History window of a branch or file
1. In Source Control Explorer, click a branch or a folder or file that is contained by a branch.
2. Click the File menu, point to Source Control, and then click View History.
3. In the History window, right-click the changeset that you want to view, and click Track Changeset.
The Select Branches dialog box appears.
4. (Optional) In the Branches list, select or clear the check boxes for the branches that you want to show or
hide.
As you select or clear check boxes, a preview of your selections appears on the right-hand side of the
dialog box.
5. (Optional) If your team has a lot of branches, click the buttons above the preview to select the branches
that you want more easily.
You can move the pointer over each button to get information about what the button does.
6. Click Visualize.
To view the Tracking Changeset window from a work item that is linked to a changeset
1. Open a work item that is linked to one or more changesets, and then click Track Work Item.
The Select Branches dialog box appears.
2. (Optional) In the Branches list, select or clear the check boxes for the branches that you want to show or
hide.
As you select or clear check boxes, a preview of your selections appears on the right-hand side of the
dialog box.
3. (Optional) If your team has lots of branches, click the buttons above the preview to select the branches that
you want more easily.
You can move the pointer over each button to show information about what the button does.
4. Click Visualize.
Overview of the Tracking Changeset Window
The following illustration shows an example of a changeset in the DinnerNow project.
Tracking Changeset window elements
The previous example illustrates how you can use the Tracking Changeset window to visualize the following
information:
The branches to which the changeset has been merged (displayed in green), including the numbers of
changesets in which the merge was implemented.
Tip:
You can click one of these branches (for example, Version2 in the previous example) to highlight all the
merges that were required for the changeset to reach that branch.
Whether the merge was a standard merge (solid line) or a baseless merge (dashed line).
If a branch has received some (but not all) of the changes in a changeset, the branch is filled with a pattern,
and an asterisk follows the changeset numbers within that branch. For example, the previous illustration
shows that only some of the changes in changeset 38 were merged to the Test branch.
The branches to which the changeset has not been merged (displayed in light blue).
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
As a project grows, typically the branch structure also grows and becomes more complex. Your team members,
especially those who are new, will require answers to simple questions such as the following:
What branches are in our project?
How are these branches related to each other?
If I need changes from another feature team, which branches will those changes have to go through to get
back to me? Who owns these branches?
The following procedures explain how to use Team Foundation version control to answer these types of questions.
IMPORTANT
This procedure can be performed on a branch and not on a folder. For example, in the following illustration you can see
which objects are branches and which are folders.
Tip: If you want to see the full hierarchy for every version control path in your project, including those
that are outside the scope of the active project in Source Control Explorer, select All hierarchies.
**B. Customize branch list button **Click this button to individually select the specific branches that you
want to show.
The Select Branches dialog box appears.
In the Branches list, select or clear the check boxes for the branches that you want to show or hide.
As you select or clear check boxes, a preview of your selections appears on the right-hand side of the
dialog box.
If your team has many branches, you can more easily specify the branches that you want by clicking
the buttons above the preview. You can point to each button to display information about what the
button does.
C. View controls on branches-If you want to fine tune details of your diagram, you can click a specific
branch and then click one of the following controls:
Click X to hide the branch (or press DELETE while the branch is selected).
Click the plus (+) symbol (or press INSERT while the branch is selected) to select or de-select which
child branches you want to display.
View Properties and Take Actions
After you view the branch hierarchy, you may need more information, or you may be ready to take some action.
You can right-click any branch in the Hierarchy window and perform any one of the following steps:
Select Properties to display the Properties dialog box, which you can use to view additional information
about the branch, including its path, who owns it, and who has permissions to work with it.
The Owner field is only for information. Being named in the Owner field conveys no additional
permissions.
Select an action such as: Branch, Merge, Compare, or Open in Source Control Explorer.
Associate a file type with a file-comparison tool
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
You can compare text files by using the default file-comparison tool integrated with Visual Studio, the Diff window.
However, you can, for file types that you specify, enable the file-comparison tool that you prefer to use. You can use
any comparison tool that supports, as command-line arguments, the full paths of the two files that you want to
compare.
Required Permissions
To perform this procedure, you must be a member of the Administrators or Users security group on the
computer where Visual Studio is installed. For more information, see Permissions and groups reference.
To associate a file type with a third-party compare tool
1. Perform either of the following sets of steps.
a. In Visual Studio, on the menu bar, choose Tools, Options.
b. In the Options dialog box, expand Source Control, choose Visual Studio Team Foundation Server,
and then choose Configure User Tools.
--or--
c. In Windows, choose Start, All Programs, Microsoft Visual Studio 2012, Visual Studio Tools,
**Developer Command Prompt **.
d. Type tf diff /configure.
2. In the Configure User Tools dialog box, choose Add.
The Configure Tool dialog box appears.
3. In the Extension box, specify the extension (for example, .cpp) that you want to associate with your tool.
Tip:
Specify .* if you want to associate all types of files with your tool.
C:\Program Files\OtherDiff\otherdiff.exe
6. In the Arguments box, type any arguments that your tool requires:
%1: The path to the source file.
%2: The path to the target file.
%5: The options that the user specified by using the /option option of the Difference command. For
more information, see Difference Command.
%6: Label ("friendly name") of the source file.
%7: Label ("friendly name") of the target file.
Tip:
For information about frequently used external tools and the arguments that they require, see the
following page on the Microsoft website: diff/merge configuration in Team Foundation - common
Command and Argument values.
%1 %2
Use quotation marks to pass white space or quotation marks to the tool.
If an argument includes one or more spaces, you must enclose it in quotation marks (""). If an argument
contains one or more quotation marks, you must add another quotation mark immediately after any
quotation mark in the argument. For example, you could specify the following argument:
%1 /title1=%6 %2 /title2=%7
Note:
This capability is not related to version-control labels, which you apply to specific versions of items in
version control, as described in Use labels to take a snapshot of your files.
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
To set up Team Foundation Version Control (TFVC ) on your dev machine, you just need to create a workspace
and then add your code.
Before you start
If you don't have Visual Studio, get it here.
If you don't have a project, create or get access to one.
(If the project you want to open is not listed, choose Select Projects and then connect to the project.)
Map the project to a folder on your dev machine.
When your team decides to branch the codebase, you can convert the Main folder to a branch. See Branch folders
and files.
When the Choose Source Control dialog box appears, choose Team Foundation Version Control.
When you are ready, check in your changes (Keyboard: Ctrl + 0, P ).
Put an existing solution under version control
You've already got an app in progress and you want to begin working on it under TFVC version control.
1. Move your solution into your workspace folder (for example:
c:\Users\YourName\Source\Workspaces\YourTeamProject\Main\).
2. If you have not already done so, open your solution, (Keyboard: Ctrl + Shift + O ) and then open Solution
Explorer (Keyboard: Ctrl + Alt + L ).
3. Add your solution to source control.
4. On the Choose Source Control dialog box, choose Team Foundation Version Control.
5. When you are ready, check in your changes (Keyboard: Ctrl + 0,P ).
Q&A
Q: I'm really new to all this; can I get more help?
A: Yes, let us walk you step by step to get started.
Q: Is your folder structure complex or do you use branches?
A: If so, you can create one or more workspaces and then optimize them to meet your needs.
Dig deeper
Develop your app in Team Foundation version control
Create and work with workspaces
5/31/2019 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Your workspace is your local copy of the team's codebase. This is where you develop and test your code in
isolation until you are ready to check in your work. In most cases the only workspace you need is created
automatically for you and you don't have to edit it.
In some cases, you might want to modify your workspace or create multiple workspaces to isolate and switch
among the changes you are making in different branches.
Choose Show remote workspaces if you want to view all the workspaces you own (including those on other
computers).
After you choose Add or Edit you can modify working folders in a new or an existing workspace.
If you want to remove the workspace, before you do so, make sure there are no pending changes (Keyboard:
Ctrl + 0, P ). If you have pending changes, you can either check them in or shelve them.
Switch workspaces
When you switch from one workspace to another, to avoid confusing yourself, make sure you switch to the same
workspace in both Team Explorer and Source Control Explorer.
1. Connect to the project (Keyboard: Ctrl + 0, C ).
2. On the home page (Keyboard: Ctrl + 0, H) choose the workspace you want to use.
3. In Source Control Explorer, choose the workspace the workspace you want to work in.
Q&A
Q: Why would I need to change the working folders? How should I do it?
A: In general, you should map your entire project to a single local folder under
c:\Users\YourName\Source\Workspaces\. For example:
Some tips on
effective folder names:
Keep all folder, sub-folder, and file names short to simplify your work and avoid potential long-path
issues that can occur with some types of code projects.
Avoid whitespace if you want make command-line operations a little easier to perform.
If your team has a large and complex codebase or if you want your workspace to contain only the files you need
to improve performance, you can optimize your workspace.
Q: Can I reuse and share folder mappings?
A: Yes. If you want to reuse or share folder mappings with other team members, you can copy the folder
mappings. Simply open the shortcut menu in the Working folders list and choose Copy. To reuse the folder
mappings, paste them into another version control workspace or a build definition workspace. To share the
folder mappings with your teammates, paste them into a text file and then share the file.
Q: What does "Cloaked" mean?
A: Choose Cloaked to exclude that folder from your workspace. For details and examples, see Optimize your
workspace.
Q: How do I add a folder non-recursively?
A: Optimize your workspace.
Q: How do I choose advanced workspace options?
A: When you choose the Advanced button, some additional options appear.
Owner: Only the owner of a workspace can use it.
Tip: Instead of changing the owner of your workspace when someone else needs to continue your
work you can suspend (or shelve) your work and then share the shelveset with them.
Computer: This box identifies the dev machine where the workspace exists, and it is read-only. You
cannot move a workspace from one computer to another. However, if the name of your dev machine has
changed and you want that change to appear in this field, run tf workspaces /updatecomputername.
Permissions: For a workspace you are using on a dev machine for a single developer, set this to Private
workspace. Choose Public workspace if you want to use a single computer for a team to collaborate
on an effort such as resolving a large number of conflicts. If you want any team member to be able to use
a workspace but not check in their work, choose Public workspace (limited). This option reserves
check-in permission for the Owner.
Location: Local is the best choice in most cases. See Decide between using a local or a server
workspace.
File Time:
Choose Checkin if you want the date and time stamp of each file to generally match the stamp of
the changeset of the version in your workspace. A few issues and exceptions are:
When you modify the local file, the date and time stamp will match the date and time when
you modified the file.
This feature is available only if you are using Visual Studio 2012 or later and Visual Studio
Team Foundation Server 2012 or later.
The setting does not apply to folders, unless there is a pending add or delete operation to a
file contained by the folder.
You might not be able to build your code project incrementally. Instead, you will have to
rebuild).
Choose Current if you want the date and time stamp to match the date and time when you last
modified the local file. For example, a team member checked in the latest change to the file on
Monday. On Tuesday, you perform a get operation to update the file. The date and time stamp is
set to Tuesday.
Q: Can I use the same workspace in multiple instances of Visual Studio?
A: Although Visual Studio does not block you from running multiple instances against the same workspace, this
usage is not supported. Also, working this way is more likely to cause problems if you are using a local
workspace.
Q: How do I add code, get code, develop my app, and check in?
Add files to the server, download files from the server, develop your app, and check in.
Q: I work at a remote site. Is there any way I can save bandwidth?
A: Install Team Foundation Proxy and set up a remote site.
Optimize your workspace
5/31/2019 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Does your team have a large and complex codebase? Do you want your workspace to contain only the files you
need to improve performance, reduce network traffic, and reduce the disk space required on your dev machine?
Optimize your folder names
Optimize your workspace using explicit, implicit, cloaked, and non-recursive folder mappings
Use workspaces to isolate and manage work among different branches
Raisa manages her work in three workspaces, each of which maps folders in a branch on the server with the
folders on her dev machine.
Note:
Branching or suspending (or shelving) are the preferred ways to isolate different work efforts against the
same codebase. However, if neither of these approaches meets your needs, you can map the same server
folder in more than one workspace. In most cases you should not need to do this. If you do map the same
server folder in more than one workspace, remember that you could have separate and different pending
changes to the same file stored in each workspace.
Decide between using a local or a server workspace
5/10/2019 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
When you create or edit a workspace, you can specify whether its location is Local or Server. In most cases,
local is best because it provides several advantages. Most notably, you can perform core version control
operations even when you're not connected to your Team Foundation Server.
Important:
One drawback to using a local workspace is that performance degrades as the number of items increases.
See the next section for details.
Tip: You can improve responsiveness by enabling asynchronous checkout. For more information, see
Manage project collection workspace settings for your team.
Tip: If working offline is important to you, then you should consider using a local workspace instead of a
server workspace See Local Workspaces earlier in this topic.
Q&A
Q: Someone checked out a file even though a check-out lock was applied to it. How did this happen?
A: The use of local workspaces makes check-out locks un-enforceable. If you have sufficient permissions you
can use the workspaces command to see the local workspaces being used in your project collection.
tf workspaces /format:detailed /owner:* /collection:https://YourServer/YourCollection/
Q: Why can't I see when some members of my team of checked out a file?
Pending changes of team members who use local workspaces are not visible to other team members in Source
Control Explorer.
Q: Is it OK to switch the location of my workspace?
A: Yes, you can change the location of your workspace from server to local or from local to server whenever
you need to. See Create and work with workspaces.
Q: Can I use the same workspace in multiple instances of Visual Studio?
A: Although Visual Studio does not block you from running multiple instances against the same workspace, this
usage is not supported. Also, working this way is more likely to cause problems if you are using a local
workspace.
Q: How does a local workspace work?
A: A local workspace caches the unmodified version of each of your files to enable you to edit, compare, and do
other things without being connected to the server.
Add Check-In Policies
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Administrators of Team Foundation version control can add check-in policy requirements. These check-in policies
require the user to take actions when they conduct a check-in to source control, for example a user can be required
to associate a work item with a changeset. For more information about check-ins, see Check In Pending Changes.
By default, the following check-in policy types are available:
Builds Requires that the last build was successful before a check-in.
Code Analysis Requires that code analysis is run before check-in.
Work Items Requires that one or more work items be associated with the check-in.
Visual Studio 2017 : Check-in policies in Visual Studio 2017 must be set through Team Explorer, tf.exe, or
through registry keys declared in the pkgdef of a Visual Studio extension. Policies only apply to a single
installation of Visual Studio 2017 on your computer. If you have multiple installations of Visual Studio 2017,
you'll need to set the check-in policy on each installation. Learn more
Procedure
To create a check-in policy
1. From Team Explorer, select the Settings page, then select Source Control under the Project section.
The Source Control Settings dialog box appears.
2. Click the Check-in Policy tab and then click Add.
The Add Check-in Policy dialog box appears.
3. In the Check-in Policy list, select the policy type you want and then click OK.
The list includes the following selections:
Select Builds if you want to require that a previous build was successful before any new changes can
be checked in.
Select Code Analysis if you want to require that code analysis is run before code can be checked in.
The Code Analysis Policy Editor dialog box appears.
Select the check boxes for the types of code analysis that you want performed. Options are Enforce
check-in to only contain files that are part of current solution, Enforce C/C++ Code Analysis
(/analyze), and Enforce Code Analysis For Managed Code. If you select the Enforce Code
Analysis For Managed Code check box, select the desired rule settings under Rule settings for
Managed Code Analysis.
For more information about how to use code analysis tools, see Create Code Analysis Check-In
Policies.
When you are finished, click OK.
If you selected Work Items, the policy is added to the list that a work item must be associated with
the check in.
4. When you are satisfied with the settings for the check-in policies, click OK; the new check-in policy now
displays with future check-ins.
See Also
Reference
Configure Command
Concepts
Set and Enforce Quality Gates
Other Resources
Walkthrough: Customizing Checkin Policies and Notes
Develop code and manage pending changes
5/31/2019 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Most changes that you make to your files are queued as pending changes. As you work, you can organize,
manage, and get details about what you've changed.
After you open your solution, open the solution explorer (Keyboard: Ctrl + Alt + L ).
When you open and modify a file from the solution explorer, the file is automatically checked out for you. Icons
appear to indicate which files you have not changed , those you have checked out , and those you have
added to the solution .
If you're working in a solution that contains a lot of files, you'll probably find it convenient to filter the solution
explorer to show only the files you have changed (Keyboard: Ctrl + [, P ).
Almost every change that you make to the files on your dev machine is stored in your workspace as a pending
change until you check it in:
add
branch
delete
edit
rename (includes moving items)
property
rollback
type (file encoding)
undelete
Work with automatically detected changes
If you are working in a local workspace, Visual Studio can detect changes that you make outside the system. If
you edit a file outside Visual Studio (for example, in Notepad) the change automatically appears in your
Included Changes.
If you add or remove a file outside Visual Studio, for example, in Windows Explorer (File Explorer in Windows 8),
the Detected changes link appears in the Excluded Changes section. Choose this link if you want to include
these changes. The Promote Candidate Changes dialog box appears. You can open the context menu of added
items and choose Browse in Windows Explorer to display them or Delete from disk to delete them.
If items that you don't need to check in appear regularly in the Promote Candidate Changes dialog box, you
can select one of them, open its context menu, and choose Ignore this local item to ignore the item. You can
also choose Ignore by extension or Ignore by file name to create a file that will cause Visual Studio to
systematically ignore this kind of file. For more information on .tfignore files, see Add files to the server.
Associate work items
It's a best practice to associate work items (such as tasks or bugs) with your changes. Under Related Work Items,
drag work items from a query or add it by ID.
Exclude changes
See Specify the files you want to check in
Note:
A few other options:
You can first put the changes away in a shelveset on your server before removing them from your
workspace.
If you have already checked in the change and want to revert it, see Roll back changesets.
Tip:
To undo all changes you have made in your solution or a code project, open the context menu, and
then choose Undo Pending Change.
2. In the Undo Pending Changes dialog box, make sure the changes you want to undo are selected, and
then choose Undo Changes.
To undo all your pending changes
On the Pending Changes page, choose the Actions link, and then choose Undo All.
Tip:
You can use this command to undo another user's check-out if you have sufficient permissions.
Next steps
When you're ready:
To request a code review of your pending changes, on the Pending Changes page, choose Request Review.
See Day in the life of an devops Developer: Suspend work, fix a bug, and conduct a code review.
If you need to set aside your changes, see Suspend your work and manage your shelvesets.
Check in and add your changes to the team's codebase, see Check in your work to the team's codebase.
Tips
If you are new to developing an app with Visual Studio and Team Foundation Server: Walk step by step with
an agile team as they collaborate to develop an app.
When you begin a new work item, it is probably a good idea for you to download the latest files from the
server before you check out files and begin your work.
Use Source Control Explorer to manage your files in version control.
Add files to the server
5/31/2019 • 9 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Adding a file to version control is often automatic when you use Solution Explorer and your project is under
version control. However, in some cases, you have to take some extra steps to add the project to version control.
TIP
Before you add files to version control, you should first set up the workspace on your dev machine
1. In Visual Studio, if you have not already done so, connect to the project.
2. Choose File, New, Project (Keyboard: Ctrl + Shift + N ).
The New Project dialog box appears.
3. Select the type of code project that you want to create.
4. In the Name box, specify the name of the code project.
5. If the Solution list appears, make sure Create new solution is selected.
6. In the Location list, specify the path to a good local working folder (such as c:\code\SiteApp\Main\) in
the workspace you created when you set up your dev machine.
Make sure the Create directory for solution and Add to source control check boxes are selected.
7. Choose OK to create the code project, which you can then view in Solution Explorer (Keyboard: Ctrl + Alt +
L ).
8. In Solution Explorer, open the context menu of the solution you created or modified and then choose
Check In to submit your pending changes.
NOTE
Avoid using the Add Solution to Source Control dialog box to upload your solution into version control. Use the following
procedure instead.
1. In Visual Studio, if you have not already done so, connect to the project.
2. Choose View, Other Windows, Source Control Explorer.
3. In Source Control Explorer, navigate to a logical parent folder for your solution, such as $/SiteApp/Main,
where SiteApp is the name of your project. Why is this a good parent folder?
4. Choose the link next to Local Path to open the parent folder in Windows Explorer (File Explorer in
Windows 8).
What do I do if the link text is "Not Mapped"?
5. Move the folder that contains your solution into the parent folder.
6. In Visual Studio, choose File, Open, Project/Solution, and then use the Open Project dialog box to open
the solution.
7. In Solution Explorer (Keyboard: Ctrl + Alt + L ), select the solution, open its context menu, and then choose
Add Solution to Source Control.
8. In Solution Explorer, select the solution, open its context menu, and then choose Check In.
9. In Team Explorer, the Pending Changes page appears.
10. Are there any Detected items shown in the Excluded Changes section?
No: Skip to the next step.
Yes: Choose the Detected link. The Promote Candidate Changes dialog box appears. The files in
listed in this dialog box are not referenced by any code projects in your solution. If your team will
need these files, make sure they are selected and then choose Promote to move them into the
Included Changes section of the Pending Changes page. For more information, see Check in
your work to the team's codebase.
11. When you're ready,submit your pending changes.
TIP
If you are creating an automated process or prefer to use the command prompt, you can use Add command instead of the
following procedures.
If you are using a local workspace, then new files are automatically detected by the Pending Changes page.
1. In Visual Studio, if you have not already done so, connect to the project.
2. Choose View, Other Windows, Source Control Explorer.
3. In Source Control Explorer, navigate to the folder where you want to add the files or folders.
4. Choose the link next to Local Path to open the target folder in Windows Explorer (File Explorer in
Windows 8).
Move your files and folders into this folder.
What do I do if the link text is "Not Mapped"?
5. In Visual Studio, in Team Explorer, choose Pending Changes.
6. On the Pending Changes page, in the Excluded Changes section, select the Detected link.
7. In the Promote Candidate Changes dialog box, make sure only files that you want to check in are
selected, and then choose Promote.
8. Submit your pending changes.
Manually add files to version control
You can also manually add files to version control.
1. Choose View, Other Windows, Source Control Explorer.
2. In Source Control Explorer, navigate to the folder where you want to place your files.
IMPORTANT
Make sure this folder is checked in before you proceed. If you are creating the folder now, open its context menu and choose
Check In, and then check in the new folder before proceeding.
3. Drag the folders or files from Windows Explorer (or File Explorer) into the folder in Source Control
Explorer.
4. When the Add to Source Control dialog box appears, make sure all the files you want to add are selected,
and then choose Include item (s).
5. Choose Finish.
6. In Team Explorer, when the Pending Changes page appears, make sure the binaries that you want to add
appear in the Included Changes section. Choose Check In.
TIP
If your dev machines and build agents can access the Internet, then NuGet may make it easier for your team to manage
your dependencies and keep your binaries up to date. You can store your packages in TFS or Azure DevOps Services using
Azure Artifacts.
The folder and workspace structure you should use to store your third-party binaries depends on the way your
solutions depend on these libraries.
Add the binaries within your folder or branch structure
If you place your third-party binaries in the same parent folder that contains your solution folders, then all your
code projects in all solutions can reference the libraries with the same relative path.
For example, a team uses this folder structure:
Every code project can then reference the libraries folder with the following relative path: ../../Lib
If, later in your project, your team needs to isolate separate efforts that require different versions of the binaries,
you can branch the library folder along with your solution folder.
For example, Version 1 an app leverages Version 1 of a library. As some developers on the Data Access team work
on the next version, they leverage Version 2. But the other teams are not yet ready to upgrade. You can use
branches to manage this kind of situation.
Raisa sets up her dev machine with two workspaces for two different efforts, each of which map in the libraries
she needs:
Customize which files are ignored by version control
By default certain types of files (for example, .dll files) are ignored by version control. As a result:
When you add ignored files to folders that are mapped in a local workspace, they do not appear in the
Pending Changes page in Team Explorer.
When you try to add ignored files using the Add to Source Control dialog box (for example by dragging
them into Source Control Explorer), they automatically appear in the Excluded items tab.
You can configure which kinds of files are ignored by placing text file called .tfignore in the folder where you want
rules to apply. The effects of the .tfignore file are recursive. However, you can create .tfignore files in sub-folders to
override the effects of a .tfignore file in a parent folder.
.tfignore file rules
The following rules apply to a .tfignore file:
# begins a comment line
The * and ? wildcards are supported.
A filespec is recursive unless prefixed by the \ character.
! negates a filespec (files that match the pattern are not ignored)
.tfignore file example
######################################
# Ignore .cpp files in the ProjA sub-folder and all its subfolders
ProjA\*.cpp
#
# Ignore .txt files in this folder
\*.txt
#
# Ignore .xml files in this folder and all its sub-folders
*.xml
#
# Ignore all files in the Temp sub-folder
\Temp
#
# Do not ignore .dll files in this folder nor in any of its sub-folders
!*.dll
IMPORTANT
This only applies when using a local workspace. Files changed when working in a server workspace will check in without
showing as a pending change in Team Explorer.
See Also
Other Resources
Decide between using a local or a server workspace
Download (get) files from the Server
5/10/2019 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
In general, you should get the latest files from the server on a regular basis so that the code you develop is
compatible with the code developed by others on your team and to minimize the risk of creating bugs when you
check in your code. You can download the latest version or a previous version of one or more files from your
Team Foundation Server to your workspace on your dev machine.
Required permissions
You must be one of the Contributors for your project. See Team Foundation Server default groups, permissions,
and roles.
Note: Keep in mind that if you get an older version of a file, make changes to it, and then try to check it in,
there is an increased chance that you will need to resolve conflicts before you can complete the check-in.
Tip: This option is equivalent to running the following command: tf get /overwrite.
4. (Optional) Select the Overwrite all files even if the local version matches the specified version
option.
If selected, files from the server overwrite all files.
Tip: This option is equivalent to running the following command: tf get /force.
5. Choose Get.
Source Control Explorer appears. If you chose Latest Version in step 5, the system updates the Latest
column with the status of Yes.
Tips
When you get files and folders from the server, the system also deletes any checked-in files from your
local workspace that have been deleted from the server. Files that have been renamed or moved on the
server are changed in your workspace to match the changes on the server.
In Source Control Explorer you can verify whether you have the latest version of a file in the Latest
column. You can see specific version information about an item by opening its shortcut menu and
choosing Properties.
If you are using a server workspace, and you have accidentally deleted some files that you want to
restore, you must use the tf get /all command to restore the deleted files.
Check out and edit files
5/31/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
When you want to edit a file you can open it from Solution Explorer or from Source Control Explorer. When you
begin editing a file, it is automatically checked out to you. In rare situations (for example, you want to check out
and lock the file to make sure your changes are checked in before changes from other team members), you might
need to manually check out (and optionally lock) an item.
Required permissions
You must be one of the Contributors for your project. See Team Foundation Server default groups, permissions,
and roles.
Important:
As a best practice, use the Lock type option with discretion and notify your teammates why you are
locking an item, and when you plan to remove the lock.
Note:
In Visual Studio Team Foundation Server 2012 this option is not available if you are using a local
workspace. Also, this lock is not enforceable because other users might be using local
workspaces. See Understand lock types.
Check In: Allow other users to check out the items you are checking out, but prevent them from
checking in their changes until you check in your changes and unlock the items.
Note:
The Lock type menu is not available if:
Another team member has locked the file.
The Enable multiple check-out option has been cleared (not a recommended practice) by an
Administrator of your project. Administrator: On the menu bar, choose Team, Project Settings,
Source Control).
If any other users have locked any of the specified items, the lock operation will fail. For more information,
see Lock and unlock folders or files.
3. Choose Check Out.
In Solution Explorer and in Source Control Explorer, a check mark appears next to the items that you have
checked out. In Team Explorer, a pending edit change to the file is displayed on the Pending Changes page. In
Source Control Explorer, a pending edit change is visible to you and to members of your team.
Tips
If you are beginning a new task, it's probably a good idea for you to download the latest files from the server
before you check out files and begin your work.
To help you and your team organize and track your work, you should use the My Work or Pending Changes
page to associate a task or a bug with the work you are doing. See Develop code and manage pending changes.
If you use a server workspace, files that you have not checked out are read-only.
You can review and manage your work, suspend your work, and ultimately contribute your work to the team's
codebase.
Check in your work to the team's codebase
5/10/2019 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Use the Pending Changes page (Keyboard: Ctrl + 0, P ) in Team Explorer to check in your code into a new
changeset.
IMPORTANT
The Check in option is not displayed if there are no pending changes to the item selected.
TIP
If you don't see pending changes for an item, make sure that it is not already listed as an excluded change. Open Team
Explorer's Pending Changes view and select the Detected: .. link under Excluded Changes. Check the changes to
include from the list and select Promote to move the excluded changes into the Included Changes section. These
changes can now be checked in.
Associate work items
When you check in changes, you should associate such work items with the changes. Benefits of doing so
include:
A team member who looks at the work item can link directly to the changeset to see the work that you did.
A team member who reviews the history of a file you changed can view the changeset and see the work
items that were the justification for the change.
If you build your changes in your automated build system (for example with a CI Build or a Gated Check-in
Build your team members can see in which completed build the task was completed or the bug was fixed.
To associate work items with your check-in:
Choose the Add Work Item by ID link in the Related Work Items section.
Drag a work item from a work item query window from Team Explorer's Work Item page into the Related
Work Items section.
Next to each work item, select how it should be related to your check-in: Associate or Resolve (available only
if the work item is not already in a state that precludes this relationship, such as Resolved, Done, or Closed).
Subscribe to alerts
If you want to be notified when someone checks in code in your TFVC project, you can subscribe to receive
email alerts. [Here's how ]
Tips
You can undock the Pending Changes page from Team Explorer and open it in a new window.
You can toggle between list and tree view from the Actions menu.
Before checking in new code, you should consider conducting a code review. See Day in the life of an
devops Developer: Suspend work, fix a bug, and conduct a code review.
You can manage and, if necessary, undo your pending changes. See Develop code and manage
pending changes.
If you need to set aside your changes, see Suspend your work and manage your shelvesets.
A check-in is performed atomically-the operation either succeeds completely or fails completely
(with one exception). If any one of the changes cannot be submitted to your Team Foundation server,
none of the changes is committed and a changeset is not created. For example, if you lose network
connectivity in the middle of a check-in, the whole operation fails.
The exception is the association of work items with the changeset. If work item association fails but all
other aspects of the check-in succeed, then the changeset is created. You can manually associate a work
item with a changeset. See Manage dependencies, link work items to support traceability.
Rename or move files and folders in TFVC
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
IMPORTANT
If you're not using TFVC for version control, use Solution Explorer to move and rename files in your current open Visual
Studio solutions or projects.
NOTE
Git version control users can move and rename files from the command line or Windows Explorer without this concern. The
changes will be reflected in Team Explorer.
1. In Visual Studio, in Team Explorer, choose Home, and then choose Pending Changes.
2. In the Excluded Changes section, choose the Detected: link.
3. In the Promote Candidate Changes dialog box, select the delete and add actions, open their shortcut
menu, and choose Promote as Rename.
4. A single rename change now appears in the Included Changes section.
Tips
You must be one of the Contributors for your project. See Team Foundation Server default groups, permissions,
and roles.
If you are beginning a new task, it's a good practice to download the latest files from the server before you
make changes to files in your workspace.
Avoid renaming an item that has been branched but not yet checked in. If you try to do so, a conflict will occur.
You can review and manage your work, suspend your work, and ultimately contribute your work to the team's
codebase.
Delete or restore files and folders in Team
Foundation Version Control (TFVC)
5/10/2019 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
You can delete files and folders from TFVC and also restore them, from both in the workspace on your dev
machine or on the server.
Requirements
See Permissions and groups reference.
Delete an item
Before you delete an item:
Before you delete a file, look for a check mark icon , which indicates pending edits in the file . If there
are pending edits, you should view them (open the context menu by right-clicking the file and choosing
Compare) and make sure that you do not need them. If you think you might need the edits in the future,
consider checking in the file before you delete it.
If you delete a folder, the system will pend delete actions for any folders and files that it contains.
If you delete a file on which other files have dependencies, the system will automatically pend delete
actions for those files. For example, if you delete a form file, the code and resource file will also be pended
for deletion.
To delete an item
1. In either Solution Explorer or Source Control Explorer, browse to the folder or file that you want to delete.
2. Select the items that you want to delete, open their context menu (right-click), and choose Delete.
TIP
If you are deleting a file from Solution Explorer, the following warning message may appear: <file name> will be
deleted permanently. The file deletion will not be implemented on the server until you check in this change. If the
file was checked in to version control before the delete, then you can recover the file. Choose OK if you want to
proceed with deleting the file.
Restore TFVC managed items deleted from your dev machine outside
of Visual Studio
From time to time you may need to restore an item you have deleted outside Visual Studio (possibly by accident).
The method you use to restore such an item depends on whether you are using a local or a server workspace. See
Decide between using a local or a server workspace.
Use a local workspace to restore an item you deleted outside Visual Studio
When you use a local workspace, Visual Studio detects and enables you to resolve changes you have made
outside the system.
To use a local workspace to restore an item you deleted outside Visual Studio
1. In Team Explorer, choose Home, and then choose Pending Changes.
2. In the Excluded Changes section, choose the Detected changes link.
3. In the Promote Candidate Changes dialog box, select an item for which delete appears in the Change
column, open its context menu (right-click), and choose Restore this item.
Use a server workspace to restore an item you deleted outside Visual Studio
When you accidentally delete an item outside Visual Studio and you are using a server workspace, when you try
to open the item in Visual Studio you may see an error message such as: TF10187: Could not open document
file name The system cannot find the file specified.. You can restore the item by getting it from the server.
To use a server workspace to restore an item you deleted outside Visual Studio
1. In Source Control Explorer, browse to the folder that contains the deleted items.
2. Open the context menu of the folder (select the folder and right-click it) and choose Get Specific Version.
3. On the Get dialog box, select Overwrite all files even if the local version matches the specified
version.
Choose Get.
TIP
You can also use the tf get /force command.
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
When you check in files to a version control folder that is controlled by a gated check-in build process, there are
some additional steps that you must take to complete the check-in.
Required permissions
You must be one of the Contributors for your project. See Team Foundation Server default groups, permissions,
and roles.
Proceed with the gated check-in after deleting the changes in your
workspace
If you want to proceed with the gated check-in operation and you do not plan to continue working with your
changes, you can delete the changes in your workspace. Your changes are preserved in a shelveset and built by the
system. If the build completes, then your changes are checked in. If the build fails, then you can unshelve the
shelveset to get the changes back into your workspace.
To proceed with the gated check-in after deleting changes in your workspace
1. Follow the steps in Begin Checking in Changes to a Folder that is Subject to Gated Check-in.
2. In the Gated Check-in dialog box:
Choose Show Options and then clear Preserve my pending changes locally.
Choose Build Changes.
3. In Team Explorer, when the information message appears in the Pending Changes page, monitor the
build by choosing the here link to display the build results window. You can also choose Home, and then
choose Builds to monitor the build on the Builds page.
4. After the build is completed:
Check-in committed: Now that your changes are checked in, you may want to get the latest version
of the files so that your workspace contains these changes. For more information, see Download
(get) files from the Server.
Check-in rejected: Correct the problems that caused the check-in to be rejected.
a. In Team Explorer, on the Builds page, under My Builds, double-click the build (or open the
shortcut menu for the build and then choose Open). The build results window appears.
b. In the build results window, look for information that can help you resolve the problem that
caused the build to fail. For some types of problems, you may be able to choose the error or
issue to view the file that requires corrections.
c. Retrieve your changes from the shelveset. For more information, see Suspend your work and
manage your shelvesets.
d. In your files, correct the problems that caused the build to fail.
See Also
Other Resources
Use a gated check-in build process to validate changes
Check In Pending Changes
Suspend your work and manage your shelvesets
Get the history of an item
5/31/2019 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
One advantage of a version control system is that you can look back in time to get detailed information about
what changes have been made to your files. Team Foundation version control maintains historical data related to
every version of every file that has ever been checked in.
Often when you look over the history of a file, folder, or branch, you are trying to solve a problem or answer a
question. By using the Team Foundation version control History window, you can more easily resolve questions
and situations such as the following:
What changes have been made in the past weeks or months?
What work item was completed by this change to the file?
Who checked in this change? What did they say about the change? What did they change?
Unexpected changes occurred in this file, causing a bug in an area of the product that we thought was
stable. Who made this change, and why did they make it?
A change in this branch fixes a bug that also needed to be fixed in other branches. How can I make sure
that the change was merged to those branches?
Use the History window to get detailed historical data about a project, branch, folder, or file.
Required permissions
You must be one of the Contributors for your project. See Team Foundation Server default groups, permissions,
and roles.
To display the History window:
In Source Control Explorer, select an item, open its shortcut menu, and then choose View History.
TIP
You can customize the position of the window by right-clicking the title and then choosing one of these options:
Float, Dock, or Dock as Tabbed Document.
Changesets Tab
The Changesets tab displays detailed data about every change that has been made to an item. All changesets
that have modified the item are listed in a table that includes the following columns:
Changeset The ID of the changeset.
User The name of the user who checked in the changeset.
Date The date and time the changeset was checked in.
Comment The comment entered by the user who checked in the changeset.
NOTE
If you open this window by using the History command and you are displaying data about a project, branch, or folder,
then the history of children items (for example, the files contained by a folder) is shown only if you use the /recursive
option.
If the item is a file, then additional data is displayed in the following columns:
Change The types of changes that were made to the file with the changeset. Examples of values that can
appear in this column include add, edit, rename, and merge.
Path The path to the file.
TIP
Sometimes you need to share this kind of data with someone else. You can select one or more rows from the table in the
Labels tab, right-click them, click Copy to copy the data to the clipboard, and then paste the data into an e-mail message,
document, or spreadsheet.
Common Tasks
By using the Changesets tab, you can perform the following tasks:
Get more details about a changeset: Right-click a Find and view changesets
changeset and then click Changeset Details to get
information such as:
Other source files that are part of the changeset.
Work items associated with the changeset.
Any check-in notes left for reviewers.
View which users made specific changes within a file: View file changes using annotate
Right-click a changeset and then click Annotate. (This
command is available only if the item is a file.)
View other branches to which this changeset has View where and when changesets have been merged
been merged: Right-click the changeset and click Track
Changeset.
Roll back changes from one changeset Select a single Roll back changesets
changeset and choose Rollback Entire Changeset.
Roll back changes from two or more consecutive Roll back changesets
changesets Select a set of consecutive changesets and
choose Rollback.
Labels tab
All labels that have been applied to the item are listed in a table that includes the following columns:
Name The name of the label.
User The user who applied the label.
Date The date and time the label was applied.
Changeset The changeset to which the label applies.
Comment The comment made by the user who applied the label.
NOTE
When you display historical data about a project, branch, or folder, the data about labels applied to children items (for
example, the files contained by a folder) is not shown.
TIP
Sometimes you need to share this kind of data with someone else. You can select one or more rows from the table in the
Labels tab, right-click them, click Copy to copy the data to the clipboard, and then paste the data into an e-mail message,
document, or spreadsheet.
Common Tasks
TASK SUPPORTING CONTENT
Edit the label: Right-click the label and click Edit Label. Use labels to take a snapshot of your files
Delete the label: **Right-click the label and click Use labels to take a snapshot of your files
**Delete Label.
Compare a past version of the item with the current Compare files Compare folders
version: Right-click a label and then click Compare to
compare a past version of the item with the current version.
Get a past version of the item: **Right-click a label and Download (get) files from the Server
then click **Get This Version to download the past version
of the item to your workspace.
View other branches to which the labeled changeset has View where and when changesets have been merged
merged: **Right-click the label and click **Track
Changeset. (This command is available only if the item is a
file.)
View which users made specific changes within the View file changes using annotate
labeled version of a file: Right-click a changeset and then
click Annotate. (This command is available only if the item is
a file.)
See Also
Other Resources
Find and view changesets
Use Source Control Explorer to manage files under version control
Use branches to isolate risk in Team Foundation Version Control
View file changes using annotate
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
You can annotate a file to learn who made changes and what changes they made in all earlier versions of the file.
Required Permissions
To perform these procedures, you must have the Read permission set to Allow. For more information, see
Permissions and groups reference.
To annotate a file
1. On the menu bar, choose View, Other Windows, Source Control Explorer.
2. In Source Control Explorer, go to the version of the file you want to annotate, open its shortcut menu,
and then choose Annotate.
The Annotated window displays the annotated file.
Each annotation appears to the left of the text that was changed and displays:
Changeset number, or Local if you have pending changes in your local workspace. To get more
information about the changeset, choose the changeset number.
The name of the person who made the change.
Date.
When you move the pointer over an annotation, the following information appears:
Path: The path of the changeset.
Changeset: The changeset number.
Owner: The name of the person who made the change.
Change: The type of change.
Date: The date of the changeset.
Lines: The line numbers where the changes were made.
Comment: The changeset check-in comment.
3. You can open the shortcut menu for an annotation, and then choose:
Changeset Details to display, in Team Explorer the Changeset Details page.
View History to open the History window.
Compare With Previous Version to compare, in the Diff window, the version you are examining
with the previous version.
If you have pending changes in your local workspace you can open the shortcut menu for the Local
annotation information and choose Compare With Workspace Version (<server name>) to
compare, in the Diff window, the version you are examining with the version you checked out from
the server.
Annotate This Version to open a new Annotate window that displays annotation information for
the selected version and all earlier versions of the file.
Track Changeset: to see to which branches the changeset has been merged. For more information,
see View where and when changesets have been merged.
Get This Version to download the selected version of the file to your local workspace.
See Also
Other Resources
Compare files
Resolve Team Foundation Version Control conflicts
Use labels to take a snapshot of your files
5/31/2019 • 10 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Labels let you take a snapshot of your files so that at a later date you can refer back to that snapshot. By using
your label, you can view, build, or even roll back a large set of files to the state they were in when you applied
the label.
Required permissions
To apply a label, you must have the Label permission set to Allow. To find, list, or view labels, you must have
the Read permission set to Allow. To modify or delete a label, you must own the label or have the Administer
Labels permission set to Allow.
Using Labels
In many software projects, when the code has reached a reasonable level of quality and stability, the team will
build and release a new version of the product. The team needs to mark the current version of each file so that
even as the files continue to change, the team can still get and build the new version of every file in their project.
Theoretically, you could record the ID of each changeset for each file manually; but clearly this kind of process is
not practical. Team Foundation version control makes the job simple: You apply a label to the folder, branch, or
project that contains the files. You can give the label a name that follows whatever naming convention you
prefer. Some examples of label names include: "Sprint 5", "M1", "Beta2", and "Release Candidate 0".
After you have applied the label, you can use it to qualify operations such as building, branching, merging,
comparing, and getting specific versions of files and folders.
Sometimes after you apply a label you decide that you need to change it. Team Foundation version control
enables you to apply a label to additional files, remove a label from certain files, and even to modify which
version of a specific file to which the label applies.
Tip:
Applying a label provides many of the same benefits as creating a branch, but typically with lower cost and
complexity. The tradeoff is that for large databases, operations such as merging may take much longer
when running against a label.
Apply a Label
Tip:
When you use Visual Studio to apply a label that already exists, the operation removes the label from all file
versions and then applies the label. From the command prompt, however, the label operation is additive.
See Label Command (Team Foundation Version Control).
Apply a label
1. In Source Control Explorer, open the shortcut menu for the collection, project, branch, folder, or file to
which you want to apply a label and choose Advanced, Apply Label.
The New Label dialog box appears.
2. In the Name box, type a name for the label.
3. (Optional) Type your comments in the Comment box.
4. In the Version list, Latest Version is selected by default. This option is the one most typically used, but if
you need the label to target a specific version, select:
Changeset: Specify the number of the changeset in the Changeset box. Alternatively, choose the
ellipses (...) to open the Find Changesets dialog box. For more information, see Find and view
changesets.
Date: Specify a date in the Date box or select a date from the calendar on the drop-down menu.
Label: Specify an existing label upon which to base the new label. Either type the label name in
the Label box, or choose the ellipses (...) to open the Find Label dialog box. For more
information, see Find, Edit, and Remove Labels.
Workspace Version: The label is created for the version in your workspace.
5. When you are satisfied with your settings, perform one of the following steps:
To apply the label, choose Create.
To apply the label and then modify it after it has been applied, choose Create and Edit. This
applies the label and then displays the Label window. For more information about using the
Label window to edit a label, see Use the Label Window to Work with Labels.
Note:
When you apply a label using a name that already exists, the system warns you and asks if you want to
continue. If you choose OK to continue, any items not contained in the path to which you are applying the
label will no longer have that label.
Rename a Label
While you cannot modify the name of an existing label, you can easily apply a new label to exactly the same files
and same versions to which another label applies.
Apply a label based on an existing label
1. In Source Control Explorer, open the shortcut menu for the project collection node (the root node), and
then choose Advanced, Apply Label.
The New Label dialog box appears.
2. In the Name box, type a name for the label.
3. (Optional) In the Comment box, type a comment.
4. In Version list, select Label.
The Label box appears.
5. Perform one of the following steps:
Type the name of the existing label.
If you are not sure of the name of the existing label, choose the browse button with the ellipses (...)
next to the Label box.
The Find Label dialog box appears.
Use the options in the Find Label dialog box to filter the list of labels and find the existing label to
which you want to apply the new label. (For more information, see Find, Edit, and Remove Labels.)
6. Choose Create.
7. (Optional) After you have created the new label, you can remove the old label. For more information, see
Find, Edit, and Remove Labels.
Tip:
You can press and hold the CONTROL or SHIFT keys and then select multiple items.
3. (Optional) If you need the label to target a specific version, from the Version list, select:
Latest Version: The label will be applied to the latest version that is in version control.
Changeset: Specify the number of the changeset in the Changeset box. Alternatively, choose the
ellipses (...) to open the Find Changesets dialog box. For more information, see Find and view
changesets.
Date: Specify a date in the Date box or select a date from the calendar on the drop-down menu.
Label: Specify an existing label upon which to base the new label. Either type the label name in
the Label box, or choose the ellipses (...) to open the Find Label dialog box. For more
information, see Find, Edit, and Remove Labels.
Workspace Version: The label is created for the version in your workspace.
4. Choose OK.
5. Choose File, Save.
Remove an item from the label
1. In the Label window, locate the collection, project, branch, folder, or file that you want to remove from
this label.
2. Open the shortcut menu for the item and choose Remove from Label.
The label is removed from the item. If the item is a project collection, project, branch, or folder, then the
label is also removed from all the items it contains.
3. Choose File, Save.
Change the version of a file
1. In the Label window, locate the file that you want to modify.
2. Open the shortcut menu for the file and choose Change Labeled Version.
3. The Change Labeled Version dialog box appears.
4. Select:
Latest Version: Apply the label to the latest version that is in version control.
Changeset: Specify the number of the changeset in the Changeset box. Alternatively, choose the
ellipses (...) to open the Find Changesets dialog box. For more information, see Find and view
changesets.
Date: Specify a date in the Date box or select a date from the calendar on the drop-down menu.
Label: Specify an existing label upon which to base the new label. Either type the label name in
the Label box, or choose the ellipses (...) to open the Find Label dialog box. For more
information, see Find, Edit, and Remove Labels.
Workspace Version: The label is created for the version in your workspace.
5. Choose File, Save.
Perform other actions on a labeled item
When you open the shortcut menu for an item in the Label window, you can also choose one of the following
commands:
View (files only)
View History
Compare (files only)
Annotate (files only)
Get This Version
See Also
Other Resources
Find and view changesets
Create and work with workspaces
Permissions and groups reference
Use branches to isolate risk in Team Foundation Version Control
Use Source Control Explorer to manage files under version control
Find and view changesets
5/31/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
When you check in your changes, they are stored on the server as a changeset. Changesets contain the history
of each item in version control.
You can view a changeset to see what the exact file changes were, discover the owner's comments, find linked
work items, and see if any policy warnings were triggered.
Required Permissions
You must be one of the Contributors for your project. See Team Foundation Server default groups,
permissions, and roles.
Find a changeset by ID
In Source Control Explorer, press Ctrl + G.
The Go to Changeset dialog box appears.
You can undock the Pending Changes page from Team Explorer and open it in a new window.
You can toggle between tree and list view from the Actions menu (Visual Studio 2013) or View Options menu
(Visual Studio 2015).
7. In the Details for Changeset dialog box, view the change types that were added and any comments,
work items, check-in notes, and policy warnings that are associated with the changeset.
8. Close the Details for Changeset dialog box.
9. Choose OK.
c:\users\jamal\workspaces\fabrikam>tf changeset
To view or modify changesets and to learn about other options, see Changeset Command.
Tips
You can download the version of a file in a changeset. See Download (get) files from the Server.
You can add a link between a changeset and one or more work items. See Manage dependencies,
link work items to support traceability.
Roll back changesets
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
A changeset is a permanent part of the history of your version-controlled items and cannot be undone or
removed. However, you can roll back the effects of one or more changesets.
Tip:
You can confirm the changes that result from rolling back some items match what you intend to do before
you commit them to the server. See Tips for details.
Required permissions
You must be one of the Contributors for your project. See Team Foundation Server default groups, permissions,
and roles.
Note:
The items you select determine the scope that the rollback changes.
2. In the Rollback dialog box, select Rollback changes from a single changeset.
Note:
The items you select determine the scope that the rollback changes.
2. In the Rollback dialog box, select Rollback changes from a range of changesets.
Tips
If your change is still pending (you have not yet checked it in), you can undo the change instead of rolling it
back. See Develop code and manage pending changes.
Like most changes you make to files, a rollback change is queued as a pending change. After you roll
back the files, you can view the files you are changing and compare the content of the files with the latest
version on the server. After you confirm the actual changes match what you intend to do, you can then
check them in.
Rollback does not delete changesets or any data. If you change your mind, use rollback to revert the
content of the files back to their state before the rollback.
Suspend your work and manage your shelvesets
5/10/2019 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
For a variety of reasons, sometimes you need to set aside some or all of your work in progress. Shelvesets are
useful when you want to stop work for:
Interruption: You have pending changes that are not ready for check in, but you need to work on a
different task.
Collaboration: You have pending changes that are not ready for check in but you need to share them
with another team member.
Code Review: You want another team member to perform a code review of your pending changes.
Tip:
If you are using Visual Studio Premium or a more powerful edition, you can use the Code Review
feature.
Private Build: Before you check in your changes, you can use your automated build system to build
and test your code.
Backup: You have work in progress that you cannot finish now so you want a backup copy that is
stored on your server and available to other team members who might need to access it.
Handoff: You have work in progress that you want to hand off to another team member.
You can move your pending changes to a shelveset on the server and then clean your workspace. The
shelveset saves and stores not only your file revisions, but also the Comment, the list of Related Work Items,
and check-in notes (if you evaluate policies before shelving).
Required permissions
You must be one of the Contributors for your project. See Team Foundation Server default groups,
permissions, and roles.
From the My Work page you can save and then restore not only your file changes and related work items, but
also the position of your open windows, breakpoints, and other important cues.
In Team Explorer, choose Home, and then choose My Work. On the My Work page, choose Suspend &
Shelve, and then type a description of the suspended work.
When you are ready to resume the work, go the Suspended & Shelved Work section of the My Work page,
select a set of suspended work, and choose Resume.
Find a shelveset
To find a shelveset
1. In Team Explorer, choose Home, and then choose Pending Changes.
2. Choose the Actions link, and then choose Find Shelvesets.
3. On the Find Shelvesets page, enter the name or alias of a project team member in the box, and then
choose the Enter key.
Tip:
If you don't know the name of the owner, you can type ***** to list shelvesets for all users.
4. A list of shelvesets appears in the Results list. You can type a filter to reduce the size of the list.
You can toggle between list and tree view from the Actions menu.
To get more information about a change to a file, open its context menu, and then choose Open, View
History, or one of the Compare options.
Choose Unshelve Changes if you want to retrieve the changes in the shelveset into your workspace:
1. For any file changes that you do not want to unshelve, open the context menu of the file, and then
choose Exclude.
2. If you want to delete the shelveset, clear the Preserve shelveset on server check box.
3. If you do not want to restore the work item list and check-in notes that are stored in the shelveset
clear the Restore work items and check-in notes check box.
4. Choose the Unshelve button.
If there are conflicts between changes in the shelveset and the file versions in your workspace, the
system will prompt you to resolve them.
Choose Delete Shelveset if you want to delete the shelveset.
Caution:
Be sure you do not need any of the work stored in a shelveset before you delete it. There is no way
to recover a deleted shelveset.
Tips
Unlike a changeset, a shelveset is a non-versioned entity. If you or another user unshelve the items of
which a shelveset consists, edit several files, and then later reshelve the shelveset, the system does not
create a new version of the items for future comparison and maintains no record of who revised the
items, when, or in what manner. The original shelveset is completely replaced.
Conflicts can occur and prevent you from resuming suspended work. If this happens, see Resolve
Team Foundation Version Control conflicts.
Compare folders and files
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
This section explains how to compare folders and files. You can compare server folders and local folders to each
other, and view the differences between the contents of each folder. You can compare two server files, two local
files, or a server file against a local file and view the differences between the files.
In This Section
Compare files
Describes how to view the differences between two server files, two local files, or a server file and a local file.
Compare folders
Describes how to compare two server folders, two local folders, or a server folder and a local folder.
Folder comparison filters
Describes the name filters that are used to match the names of files or folders you are comparing.
Reconcile differences between two folders
Describes how to reconcile the differences between a server folder and local folder, and how to resolve conflicting
pending changes in your local folder.
Associate a file type with a file-comparison tool
Describes how to associate a specific file type with a third-party compare or difference tool.
Compare files
6/4/2019 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
This article provides a guide for comparing files when using Team Foundation Version Control (TFVC ). If you're
using Git for version control, see comparing files with Git and Visual Studio.
NOTE
Even if you're not using version control, you can use the Diff window in Visual Studio to compare two files. To open the
Diff window directly in Visual Studio, you can use the devenv.exe tool with the /diff option from the Developer Command
Prompt to compare any two files on your computer.
TIP
To compare any two local files, select Local Path... from both Browse... drop downs in the Compare dialog.
4. Choose OK.
Choose Compare with Latest Version to see how the changes you have made compare to the
latest version of the file on your Team Foundation Server.
4. The Diff window appears. You can continue to make changes to the file in this window.
TIP
You can also use Solution Explorer and the Source Control Explorer windows to compare the file in your workspace
with a version of the file on the server. Select a file, open its shortcut menu (right-click), and then choose Compare.
When the Compare dialog box appears, choose OK.
NOTE
Even if you're not using version control, you can use the Diff window in Visual Studio to compare two files. To open the
Diff window directly in Visual Studio, you can use the devenv.exe tool with the /diff option from the Developer Command
Prompt to compare any two files on your computer.
Deleted text
Added text
Changed text
Code review comment
Visual summary of the differences between the files
Here are some tips for working with the Diff window:
Although Side-by-side mode is generally more effective in most cases, you can use whichever mode
works best for you and the code you are examining.
To skip:
To the next difference, choose Next difference (Keyboard: F8).
To the previous difference, choose Previous difference (Keyboard: Shift+F8).
Back and forth in the file, choose a section of the visual summary.
When you participate in a code review, you use the Diff window to see the code changes that are the
subject of the review. For more information, see Day in the life of a devops Developer: Suspend work, fix
a bug, and conduct a code review.
File1 and File2 are the full path to the files you want to merge. The Base file is the full path to the file both
files are based off of, and Result file is the full path to where you want to write the merged results.
See Also
Compare folders
Compare folders
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
You can compare the differences between two server folders, two local folders, or a server folder and a local
folder.
Required Permissions
To perform these procedures, you must have the Read permission set to Allow. For more information, see
Permissions and groups reference.
Note:
To compare two local folders, you do not need Team Foundation Server permissions.
See Also
Other Resources
Folder comparison filters
Compare files
Reconcile differences between two folders
Folder comparison filters
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
The folder comparison filter is an ordered list of name filters that is used to match the names of files or folders
that you are comparing. You can use Compare to evaluate the file or folder names against the name filters. Once
Compare finds a match or exclusion, the comparison stops.
The default name filters are as follows:
!*.pdb;!*.obj;!*.dll;!*.exe;!*.res;!*.resources;!*.cache;!*.ilk;!*.ncb;!obj\;!objd\;!bin\
Name Filters
The following wildcard characters have special meaning when they are used in a name filter:
? - Matches exactly one character.
* - Matches zero or more characters.
! - Specifies an exclusion name filter.
\ - Specifies a folder name filter.
; - Name filter delimiter.
IMPORTANT
The following characters are not allowed in name filters: " < > | \b \0 \t and characters 0-31.
The name filters are applied to the file and folder names by using the following rules:
When Compare evaluates a file or folder name, it compares the name to each filter in the order that you
specified the filters. As soon as the file or folder name matches a filter, the name is a match and it is not
compared against the remaining filters.
A folder filter must end with the \ wildcard character.
An exclusion filter must begin with the ! wildcard character.
If you specify any filters that are not the exclusion filter, only files or folders that match the specified filters
are included in the results.
If you specify an exclusion filter, all files or folders that do not match the exclusion filter are included in the
results.
If you want to exclude a subset of file or folder names, you must specify the filter for the file or folder name
that you want to match first and then specify the exclusion filter.
Examples
The following table lists filter name mask examples.
NAME MASK DESCRIPTION
FILTER DESCRIPTION
*.cs;!objd\;!obj\;!bin\ Matches all C# files except those in objd, obj, or bin folders.
!*.resx;!*.ini;!resources\;!*junk*\ Excludes all .resx and .ini files, all files in the resources folder,
and all files in any folder that has a name that includes the
word junk.
See Also
Other Resources
Compare folders
Reconcile differences between two folders
Reconcile differences between two folders
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
After you compare a server folder and a local folder, you can reconcile the differences between the folder contents
and between files that have conflicting pending changes in your local folder. For more information, see Compare
folders.
Required Permissions
To perform these procedures, you must have the Read and Check out permissions set to Allow. For more
information, see Permissions and groups reference.
Note: To reconcile two local folders or files, you do not need Team Foundation Server permissions.
To reconcile differences
1. In Source Control Explorer, right-click a folder, and then click Compare.
The Compare dialog box appears.
2. In the Compare dialog box. select the folder versions to compare. For more information see Compare
folders.
The Folder Difference window appears.
3. In the Folder Difference window, right-click the folder or file you want to reconcile, and click Reconcile.
Note: You can select multiple folders and files by holding down the CTRL key and clicking additional
folders or files. Also, you can press CTRL+A to select all folders and files.
See Also
Other Resources
Compare folders
Compare files
Resolve Team Foundation Version Control conflicts
Resolve Team Foundation Version Control conflicts
5/31/2019 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
An advantage of using Team Foundation version control to manage your files is that several people can work
concurrently on a file. One drawback is that sometimes you must resolve conflicts before you can get, check in,
unshelve, merge, or roll back your files.
Although it can be frustrating to encounter conflicts, the system provides information and tools to help you
understand and resolve conflicts.
Resolve conflicts
AutoResolve all conflicts
AutoMerge an individual conflict
Manually resolve an individual conflict
Understand the automatic options
Work from the command prompt
Get tips
Resolve conflicts
Use the Resolve Conflicts window to resolve conflicts that are blocking you.
By default, the
window shows only the conflicts caused by the most recent operation you attempted. When the window is in
this state, a message appears that begins: Path filter applied. To show all conflicts in your workspace, choose
Get All Conflicts. A message that begins with: n Conflict(s) appears.
If a lot of time has passed since you made changes to files in your workspace, new conflicts might have
occurred. To refresh the Resolve Conflicts window, choose Refresh.
Each conflict contains information and sometimes links that might help you resolve it. To get more information,
you can select the conflict and choose:
History to see the history of the file. If the operation that caused the conflict is a Merge or a Rollback,
then you can choose the menu control to the right of History and then select either Source History or
Target History.
See Get the history of an item.
Annotate to view details on all changes that were made to the most recent version of the file,
including who made each change and when they made it. See View file changes using annotate.
Compare (or the menu to the right of the button and then choose a command). The Diff window
appears.
Non-conflicting content changes In the file version on the left, a Conflicts with any content
were made in each version of a file zero was added at the beginning. changes
In the file on the right, a three
was added at the end:
Content changes were made that four and five were added to the Conflicts with content changes
are unique to the workspace workspace or target version: made only in the local
(during get or checkin operation) workspace or target branch
or target version (during merge or
rollback operation)
Content changes were made that four and five were added to the Conflicts with content changes
are unique to the server (during server or source version: made only in the server version
get or checkin operation) or or source branch
source version (during merge or
rollback operation)
A file on the server (during get or You checked out a file that is Conflicts caused by renaming
checkin operation) or in the named launch.cs and worked on file in the server version or
source branch (during merge or it. During that time, someone else source branch
rollback operation) was renamed checked in a changeset that
affected the same file. That
changeset did not modify the
contents of the file, but it did
change the name of the file to
start.cs.
Common content changes Changes to each version resulted Conflicts caused by identical
were made that resulted in in identical file content. The change in the server and
identical content in each changes can be to the content in workspace
version the files, as shown in the following
example:
You changed a file,
checked it in through a
Gated Check-in build, and
selected the Preserve my
pending changes locally
option
This option also resolves conflicts
that are caused by all other
operations (for example, rename,
delete, undelete, and branch) and
that result in identical files.
TIP
Tips
By default the system automatically attempts to AutoResolve All conflicts. To change the option,
from the menu bar choose Tools, Options, and then in the Options dialog box, navigate to Source
Control, Visual Studio Team Foundation Server. Clear the Attempt to automatically resolve
conflicts when they are generated checkbox.
Does your team need to collaborate to resolve a large number of conflicts (for example, which might
occur after merge operation in a large codebase)? If so, a public workspace on a shared dev machine
might help. See Create and work with workspaces.
Understand lock types
5/10/2019 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
You can use the lock command to temporarily prevent changes to a particular file or folder in the source control
server. This can be helpful if you want to change an item in your workspace and then check it in without being
forced to resolve any merge conflicts. Only one user at a time may hold a lock on a particular file or folder. If you
want to prevent access to an item in a persistent way, you should use the Permission Command instead.
Lock Types
Team Foundation provides two types of locks: check-in locks and check-out locks.
Check-in lock
A check-in lock is less restrictive than a check-out lock. When you apply a check-in lock, users can continue to
make local changes to the item in other workspaces. But those changes cannot be checked in until you explicitly
remove the check-in lock from the item or implicitly remove it by checking in your changes to the file.
Check-out lock
In Visual Studio Team Foundation Server 2012, check-out locks are generally not effective because of local
workspaces (see Decide between using a local or a server workspace ). Specifically, check-out locks are:
Not enforceable because other users might be using local workspaces.
Not available if you are using a local workspace.
Disabled if a member of the Administrators security group of your project collection has enabled
asynchronous checkout for your team's server workspaces.
A check-out lock prevents users who are using server workspaces from checking out and making changes to the
locked item in their workspaces. You cannot apply a check-out lock to an item for which any pending changes
exist, in any workspace other than your own.
Note:
By default, the UnlockOther permission is granted to administrators only. If you have the UnlockOther
permission, you can remove a lock from an item in the workspace of another user by using the Lock
Command.
See Also
Other Resources
Work with version control locks
Create and work with workspaces
Resolve Team Foundation Version Control conflicts
Lock and unlock folders or files in Team Foundation
Version Control
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
NOTE
This content applies to files managed by Team Foundation Version Control (TFVC) that you need to lock or unlock. For help
unlocking files in use by programs on your PC, use the Handle and Process Explorer tools to help you find which program
that is locking your file(s).
A folder or file tracked by TFVC can be locked or unlocked to deny or restore the user's privileges. Privileges
include checking out an item for edit into a different workspace or checking in Pending Changes to an item from a
different workspace. For more information, see Create and work with workspaces.
You can use a lock to temporarily freeze the server version of an item so that you can check in a pending change
without having to resolve any merge conflicts. If you want to permanently prevent access to an item on the server,
you should use the Permission Command instead.
TIP
You can use the Lock command to remove another user's lock if you have sufficient permissions.
Requirements
See Permissions and groups reference.
To lock a folder or file from Source Control Explorer
IMPORTANT
These options will appear only when you are making changes in a server workspace. The use of local workspaces in your
Project makes check-out locks un-enforceable. Learn more.
1. On the View menu, choose Other Windows,and then choose Source Control Explorer.
You can also double-click Source Control in Team Explorer.
2. In Source Control Explorer, right-click on the file you want to apply a lock, and select Advanced.., then
Lock.. (Visual Studio 2015) or Lock.. (Visual Studio 2013)
3. In the Lock dialog box select the file or folder you want.
4. Choose either the Check Out lock or the Check In lock type, and then choose Lock . Learn more about
TFVC lock types.
Under Pending Changes, Source Control Explorer displays the status: lock. The next time your pending
changes are checked into the workspace, the lock will be removed. For more information, see Check in your
work to the team's codebase and understanding locks
NOTE
You can also lock folders and files from the command line. For more information, see Lock Command.
IMPORTANT
You can only unlock files other members of your team have locked if you have UnlockOther permissions. If you don't have
permission to unlock a file the option will be inaccessible.
1. While working in the server workspace, navigate to the View menu and choose Other Windows, then
choose Source Control Explorer.
2. In Source Control Explorer, open the shortcut menu for the folder or file from which you want to remove a
lock, and then choose Unlock.
See Also
Other Resources
Understand lock types
Lock Command
Use Source Control Explorer to manage files under version control
Set repository permissions for Git or TFVC
7/23/2019 • 6 minutes to read • Edit Online
Azure DevOps Services | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | TFS 2013
By default, members of the project Contributors group have permissions to contribute to a repository. However, to
create and manage permissions for a repository, you must be a member of the Project Administrators group. You
can grant or restrict access to a repository by setting the permission state to Allow or Deny for a single user or a
security group.
Prerequisites
You must have a project. If you don't have a project yet, create one in Azure DevOps or set one up in an on-
premises TFS.
You must be a member of the Project Administrators Group or have your Manage permissions set to Allow
for Git repositories or the TFVC repository.
Set permissions across all Git repositories by making changes to the top-level Git repositories entry. Individual
repositories inherit permissions from the top-level Git Repositories entry. Branches inherit a subset of
permissions from assignments made at the repository level. For branch permissions and policies, see Set branch
permissions and Improve code quality with branch policies.
By default, the project-level Readers groups have read-only permissions.
Note Management: Can push and edit Git notes to the repository.
They can also remove notes from items if they have the Force
permission.
Tag Creation: Can push tags to the repository, and can also edit or
remove tags if they have the Force permission.
The Project Collection Build Service can read from all repositories by default. Any pipeline which runs with project
collection scope can potentially read any repository in the organization/collection. You can remove this permission
for a repository: set "Read" to "Deny" for the Project Collection Build Service.
TFVC
Team Foundation Version Control (TFVC ) provides a centralized version control system to manage your source
control.
Otherwise, choose a specific repository and choose the security group whose permissions you want to
manage.
NOTE
If you add a user or group, and don't change any permissions for that user or group, then upon refresh of the
permissions page, the user or group you added no longer appears.
Related articles
Default Git permissions
Default TFVC permissions
Default permissions and access
Permissions and groups reference
Use Team Foundation version control commands
5/31/2019 • 11 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
You can use version control commands to do nearly all tasks you can do in Visual Studio, and also several tasks
that can't be done in Visual Studio. You can use the tf.exe tool to run version control commands from a
command prompt or within a script.
Run a command
To launch the Visual Studio command prompt, from Windows Start, choose Visual Studio 2015, then choose
the Developer Command Prompt for V2015 shortcut.
Visual Studio 2017 users: The tf.exe binary is no longer in a fixed location in the Visual Studio install path
as in previous releases (for example, C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE ).
Scripts using tf.exe should not hardcode a path to the file based on the Visual Studio 2017 install path.
In most cases, you run the version control command in the context of a directory that is mapped in the
workspace. For example, $/SiteApp/Main/ is mapped to c:\\code\\SiteApp\\Main\\ . To get the latest version of
all items in the workspace:
c:\code\SiteApp\Main\SolutionA>tf get
TIP
Examples
c:\code\SiteApp\Main>tf get
readme.txt /v:C8
-- or --
c:\code\SiteApp\Main>tf get
readme.txt /v:8
-- or --
c:\code\SiteApp\Main>tf get
readme.txt;8
c:\code\SiteApp\Main>tf get
readme.txt;LJulyHotFix
c:\code\SiteApp\Main>tf get
/version:LLastKnownGood
If she wants to avoid having her password appear in the command prompt, she can enter the command
without the password:
After she enters this command, the system then prompts her to type her password in a dialog box that masks
her input.
Use the /lock option to apply or remove a lock
IMPORTANT
As a best practice, use the /lock option with discretion and notify your teammates why you are locking an item, and
when you plan to remove the lock.
Use the /lock option to apply or remove a lock at the same time you run another command such as Add or
Edit.
/lock:(none|checkin|checkout)
Note:
In a few cases, the lock operation can fail:
If any other users have locked any of the specified items, the lock operation will fail.
The system ignores this switch if there is already a pending change to the item. In this case, you must
use the Lock Command to change a lock on an item.
/comment -C
/computer -M
/delete -D
/force -P
/format -F
/help -?, -H
/lock -K
/login -Y
/newname -N
/noprompt -I
/owner -O
/recursive -R
/server -S
/slotmode -X
/template -T
/user -U
/version -V
/workspace -W
0 Success.
2 Unrecognized command.
For example:
If one of the files you are trying to check out does not exist on the server, the command returns 1 to indicate
partial success.
Git permission command
5/31/2019 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Modifies the user access control list (ACL ) and displays authorization settings for a git repository or branch within
a git repository.
Requirements:
To view permissions, you must be able to view the artifact for the type of information you are requesting:
View collection-level information for project collections, View project-level information for projects,
and Read for repository (and branch if you are viewing branch permissions).
To manage permissions, you must have Manage permissions for the desired artifact.
For more information, see Permissions and groups reference.
Parameters
PARAMETER DESCRIPTION
/user:username1[,username2,...] The user or users for which to allow, deny, or remove. You
must specify at least one user or group.
/group:groupname1[,groupname2,...] The groups or groups for which to allow, deny, or remove. You
must specify at least one user or group. Groups and
individuals can be used together.
/collection:TeamProjectCollectionUrl Specifies the URL of the project collection that contains the
permissions to view or modify. For example:
http://myserver:8080/tfs/DefaultCollection or
https://fabrikam-fiber.visualstudio.com. This parameter is
required.
PARAMETER DESCRIPTION
/repository:RepositoryIdentifier Specifies the name of the repo that contains the permissions
to view or modify.
/login:username,[password] Specifies the user account to run the command. See Use Team
Foundation version control commands.
See Git repository permission namespaces and actions for a list of the permissions that can be administered by the
tf git permission command.
Examples
NOTE
The following examples are broken into multiple lines for readability. To copy and paste them into the command-line and run
them, first copy them and paste them into notepad or another tool and edit them so the commands are contained on a
single line.
Finally, allow administrators to create a branch called master (in case it ever gets deleted accidentally).
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Retrieves a file from a Git repository to a temporary location on your computer and displays it.
Requirements: See Permissions and groups reference.
Parameters
PARAMETER DESCRIPTION
/collection:TeamProjectCollectionUrl Specifies the URL of the project collection that contains the file
to view. For example:
http://myserver:8080/tfs/DefaultCollection or
https://dev.azure.com/fabrikam-fiber. This parameter is
required.
/teamproject:TeamProjectIdentifier Specifies the name of the project that contains the repo. This
parameter is required.
/repository:RepositoryIdentifier Specifies the name of the repo that contains the file to view.
This parameter is required.
/path:path Specifies the path of the file. This option cannot be used with
the blob parameter. One of either path or blob is required.
/commitId:commitId Specifies the commit that contains the file to open for viewing.
If you omit this option, view retrieves the latest version from
the default branch (typically master). This parameter can only
be used with the path option.
/output:localfile The path and name under which to save the retrieved file. If
not supplied, the file is saved in %Temp%\TFSTemp .
/console Specifies that the file output should be directed to the console.
This is useful if you want to write the file out to disk using
console redirection (with a different name or location than the
versioned item).
PARAMETER DESCRIPTION
/login:username,[password] Specifies the user account to run the command. See Use Team
Foundation version control commands.
Examples
The following example retrieves a file from the default branch (typically master) and saves it to the current folder,
and prompts the user for their credentials.
NOTE
The following examples are broken into multiple lines for readability. To copy and paste them into the command-line and run
them, first copy them and paste them into notepad or another tool and edit them so the commands are contained on a
single line.
The following example retrieves a file from the default branch (typically master), and does not prompt for
credentials since they are supplied.
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Adds files and folders to version control.
Tip:
Before you add files to version control, you should first set up the workspace on your dev machine. See
Workspace Command or Set up Team Foundation Version Control on your dev machine.
Parameters
PARAMETER DESCRIPTION
itemspec Specifies the scope of the items to add. You can specify more
than one itemspec argument.
/login:username,[password] Specifies the user account to run the command. See Use Team
Foundation version control commands.
/noignore By default certain types of files (for example, .dll files) are
ignored by version control. The rules in a .tfignore files apply
to the Add command when you specify a wildcard in your
itemspec. To override the application of the rules in this case,
specify /noignore.
You can configure which kinds of files are ignored using a
.tfignore file (see Add Files: .tfignore file).
Examples
In all the following examples, assume that $/SiteApp/Main/ is mapped to c:\\code\\SiteApp\\Main\\ in the
workspace.
Add all new files in a local workspace
New files in a local workspace are automatically detected. You can promote these newly detected files to your
pending changes.
c:\code\SiteApp\Main\SolutionA\Project1>tf add
Adds the latest versions of all items (except those that are ignored) in a local workspace.
Adds all C# code files (.cs) in the current directory and any subdirectories.
Tips
The results of this command are queued as pending changes (see Status command) and do not take effect on
the server until you check in (see Checkin command).
If you need to set aside changes (and perhaps also want to clean your workspace for another task), use the
Shelve Command.
Checkin command
5/31/2019 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Checks in your pending changes to files or folders to the server.
Almost every change that you make to the files on your dev machine is stored in your workspace as a pending
change until you check it in. When you check in your changes, they are stored as a changeset on the server.
Although the Checkin command provides a different user interface than the one you can use in Visual Studio
(see Check in your work to the team's codebase), the process is fundamentally the same.
Requirements: See Permissions and groups reference.
Parameters
PARAMETER DESCRIPTION
/author:author name Identifies the author of the pending changes so that one
user can check in changes on behalf of another user.
Requires the CheckinOther permission. See Permissions
and groups reference
/login:username,[password] Specifies the user account to run the command. See Use
Team Foundation version control commands.
NOTE
NOTE
Examples
Check in all pending changes in the current workspace
c:\code\SiteApp\Main>tf checkin
Displays the Check In dialog box, which displays all pending changes in the current workspace. You can use the
Check In dialog box to select or clear the pending changes you want to check in, add a comment, associate work
items, and perform other tasks and then choose the Check In button when you are ready to proceed.
Check in all pending changes with a comment
c:\code\SiteApp\Main>tf checkin /comment:"Re-implemented Pi calculator"
Checks in all pending changes in the current workspace and provides a comment to help your teammates
understand the purpose of your changes.
Check in a change to a single item without using the Check In dialog box
Checks in your pending changes to program.cs. The Check In dialog box is not displayed, and if any conflicts
block the check in, the system does not display the conflicts window.
Tips
To set aside changes (and perhaps also want to clean your workspace for another task), use the Shelve
Command.
If conflicts block your check-in, you can use the Resolve Command to resolve them.
If a machine and user account do not have a workspace mapped to the Project Collection that contains
the shelveset, you can use the /shelveset and /collection options to check in a shelveset.
Checkout (or Edit) command
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Checks out a file and changes its pending change status to Edit. You can call this command using either
Checkout or Edit.
Requirements: See Permissions and groups reference.
Parameters
PARAMETER DESCRIPTION
itemspec Specifies the scope of the items to check out. For syntax, see
Use Team Foundation version control commands.
/login:username,[password] Specifies the user account to run the command. See Use
Team Foundation version control commands.
Examples
Check out a single item
Tips
If you are beginning a new task, it's probably a good idea for you to download the latest files from the
server before you check out files and begin your work. See Get command.
When you begin editing a file in a local workspace, it is automatically checked out for you.
You can view a list of your pending changes:
And work with related data such as Comments and Associated Work Items in the Check In dialog
box using the Checkin command.
At the command prompt by using the Status command.
When you are ready to check in your changes to the team's codebase on the server, use the Checkin
command.
If you need to set aside changes (and perhaps also want to clean your workspace for another task), use
the Shelve Command.
If you use a server workspace, files that you have not checked out are read-only.
Get command
5/31/2019 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Gets (downloads) either the latest version or a specified version of one or more files or folders from Team
Foundation Server to the workspace. Although the Get command provides a different user interface than
Visual Studio (see Download (get) files from the Server), the process is fundamentally the same.
Requirements: See Permissions and groups reference.
Parameters
PARAMETER DESCRIPTION
itemspec Specifies the scope of the items to get. You can specify
more than one itemspec argument. If no itemspec is
provided, the system recursively gets all items in the
current workspace.
For syntax, see Use Team Foundation version control
commands.
/login:username,[password] Specifies the user account to run the command. See Use
Team Foundation version control commands.
Examples
In all the following examples, assume that $/SiteApp/Main/ is mapped to c:\\code\\SiteApp\\Main\\ in the
workspace.
Get the latest version of all items in a workspace
c:\code\SiteApp\Main\SolutionA>tf get
Gets the latest versions of all items in the workspace. For example, the above command would recursively get
all files in $/SiteApp/Main/ including all its child folders.
Recursively get the latest version of items of a certain type in a folder
Synchronizes the workspace to match the codebase as it existed when changeset 15 was created:
The name and content of every item in the workspace is changed to match the state it was in on the
server.
Items that were deleted after that changeset are restored to the workspace.
Items that were added after that changeset are deleted from the workspace.
Synchronize a workspace to match a labeled version of the team's codebase
Synchronizes the workspace to match the items in the codebase that are labeled LastKnownGood:
The name and content of every labeled item in the workspace is changed to match the state it was in on
the server.
Labeled items that were deleted are restored to the workspace.
Items that are not labeled on the server are deleted from the workspace.
Tips
If you are beginning a new task, it's probably a good idea for you to run tf get (you can do so from
any directory in your workspace) to download the latest files from the server before you check out files
and begin your work.
As needed, this command creates folders on disk to contain the child items that the command is
downloading.
You can view information about the history of an item using the History command and the Changeset
Command.
If you are concerned about what changes might occur to the files in the workspace, you can use the
/preview option to see the changes that would occur without actually implementing them.
Conflicts could block your get. A typical cause of conflicts is trying to get an item on which you have
pending changes. You can use the Resolve Command to resolve these conflicts.
History command
5/31/2019 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Displays the revision history of one or more files or folders. The data is displayed in either the History window, or
if /noprompt option is specified, at the command prompt.
Requirements: See Permissions and groups reference.
Parameters
PARAMETER DESCRIPTION
/collection: TeamProjectCollectionUrl Specifies the URL of the project collection that contains
the items. For example:
http://myserver:8080/tfs/DefaultCollection.
By default, the project collection is presumed to be the
one that contains the workspace that maps the current
directory.
/login:username,[password] Specifies the user account to run the command. See Use
Team Foundation version control commands.
/sort Sorts the revision history for one or more files or folders
in either of the following orders:
Ascending: from the oldest to the most recent
revision.
Descending (default): from the most recent to
the oldest revision.
You must use the /noprompt option with this option.
Displays all changes made to program.cs in the command prompt window. For example:
Displays all changes made to all items in SolutionA (including those in subfolders) in the History window.
Get history of the last five changes to all items in a folder
Displays the latest 5 changes made to items in SolutionA (including those in subfolders):
Displays changes made to all items in SolutionA (including those in subfolders) in version 30 and earlier:
-- or --
Displays changes made to all items in SolutionA (including those in subfolders) on 4/23/12 or earlier:
Displays changes made to all items in SolutionA (including those in subfolders) between 4/12/2012 and
4/23/12:
Displays details about changes made to all items in SolutionA (including those in subfolders) between
4/12/2012 and 4/23/12:
Changeset: 30
User: Raisa Pokrovskaya (Fabrikam)
Date: Monday, April 23, 2012 1:23:05 PM
Comment:
Much better name for this file
Items:
rename $/SiteApp/Main/SolutionA/Project1/programBig.cs
delete, source rename $/SiteApp/Main/SolutionA/Project1/program3.cs;X15
-------------------------------------------------------------------------------
Changeset: 29
User: Raisa Pokrovskaya (Fabrikam)
Date: Monday, April 23, 2012 1:03:13 PM
Comment:
Fix bug in new method
Items:
edit $/SiteApp/Main/SolutionA/Project1/program1.cs
edit $/SiteApp/Main/SolutionA/Project1/program2.cs
-------------------------------------------------------------------------------
Changeset: 20
User: Raisa Pokrovskaya (Fabrikam)
Date: Thursday, April 12, 2012 5:09:35 PM
Comment:
Add new method, add program2.cs to Project1
Items:
add $/SiteApp/Main/SolutionA/Project1/program2.cs
Check-in Notes:
Documentation:
An important new part of our codebase.
Policy Warnings:
Override Reason:
Jamal agrees with me that we can bypass for this check-in.
Messages:
The Code Analysis Policy requires files to be checked in through Visual
Studio with an open solution.
c:\code\SiteApp\Main\SolutionA>tf history .
Displays the history of the SolutionA folder in the History window, which enables you to explore earlier changes
to the folder. For example, if the most recent change to the folder was a rename, you can expand the changeset to
see changes that occurred before the rename.
Displays the most recent change to the SolutionA folder in the command prompt window.
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Displays information about pending changes to files and folders in one or more workspaces. Or, when you use
the /shelveset option, displays information about pending changes in a shelveset.
Requirements: See Permissions and groups reference.
Parameters
ARGUMENT DESCRIPTION
/collection: TeamProjectCollectionUrl When you use the /workspace option, specifies the URL
of the project collection that contains the workspace that
contains the pending changes. For example:
http://myserver:8080/tfs/DefaultCollection. If not
specified, by default the project collection is presumed to
be the one that contains the workspace that maps the
current directory.
Ignored if you do not use the /workspace option.
NO TE
NO TE
/workspace workspacename[;workspaceowner] Specifies the name of the workspace that contains the
pending changes. If not specified, the workspace is the
one that maps the current directory.
You can specify workspaceowner to get data about
pending changes in a workspace that belongs to a
specific user. If not specified, the workspace is presumed
to be the current user, or if specified, the
/login:username.
This option cannot be combined with the /shelveset
option.
NO TE
Remarks
You can use the Status command to view pending changes in the current workspace (for example, the workspace
that maps the current directory in the command prompt window ) regardless of whether it is a local workspace or
a server workspace. You can also use this command to view pending changes in a remote server workspace (for
example, changes made by another user on another dev machine) by using the /collection, /user, and
/workspace options. However, you cannot view pending changes in a remote local workspace.
Also see: Decide between using a local or a server workspace.
Examples
In all the following examples, assume that $/SiteApp/Main/ is mapped to c:\\code\\SiteApp\\Main\\ in the
workspace.
List all changes in the current workspace
c:\code\SiteApp\Main\SolutionA\>tf stat
Lists pending changes to all items in the SolutionA folder, including those in its subfolders).
Tips
Most changes you make to files under version control are queued as pending changes in your workspace. See
Develop code and manage pending changes and Create and work with workspaces.
You can use the Difference Command to get details about edit changes (changes to the content) in a file.
If you need to set aside changes (and perhaps also want to clean your workspace for another task), use the
Shelve Command. For more information about shelvesets, see Suspend your work and manage your
shelvesets.
When you are ready to check in changes to the server, use the Checkin command.
Undo command
5/31/2019 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Discards one or more pending changes to files or folders.
Requirements: See Permissions and groups reference.
tf undo [/workspace:workspacename[;workspaceowner]]
[/recursive] itemspec [/noprompt] [/login:username,[password]]
[/collection:TeamProjectCollectionUrl]
Parameters
PARAMETER DESCRIPTION
/collection : TeamProjectCollectionUrl Specifies the URL of the project collection that contains
the items. For example:
http://myserver:8080/tfs/DefaultCollection.
If you do not use the /workspace option, by default the
project collection is presumed to be the one that contains
the workspace that maps the current directory.
itemspec Specifies the scope of the items. You can specify more
than one itemspec argument. For syntax, see Use Team
Foundation version control commands.
NO TE
Remarks
For each item on which there is a pending edit change, the undo command determines if the file has been
modified on disk. If the file has been modified and the /noprompt option has not been specified, the system
prompts you to confirm that you want to proceed. Choose the N key to leave the change in place, the Y key to
proceed with only the current change, or the A key to proceed with this and any other modified files that are
subsequently detected.
The undo command removes any locks on the items.
Examples
Remove pending changes to a file
Removes all pending changes in the c:\code\SiteApp\Main folder and all its subfolders.
Remove pending changes to a file in a remote workspace
Removes all pending changes to program.cs in the specified collection and workspace.
Tips
To view a list of pending changes in the current or in a remote workspace, use the Status command.
You can use the /workspace option (and as needed, the /collection option) to undo changes on a remote dev
machine. This capability is especially useful in cases when, for example, a file has been checked out and
possibly locked on a dev machine that you cannot access. See the above explanation of the /workspace for
information about how this works.
If you need to clean your workspace (for example, because your work is interrupted by a more urgent task)
and want to preserve the pending changes instead of undoing them, you can suspend them. See Shelve
Command. You can also preserve the position of your open windows, breakpoints, and other important cues.
See Suspend your work and manage your shelvesets.
You can also discard changes that have already been checked in. See Undelete Command and Rollback
Command (Team Foundation Version Control).
Delete Command (Team Foundation Version Control)
5/31/2019 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Removes files and folders from the Team Foundation version control server and deletes them from the disk.
NOTE
The results of this command are not visible in other workspaces until you perform a check-in operation. For more
information, see Check In Pending Changes.
Required Permissions
To use the delete command, you must have the Check out permission set to Allow. If you include the /lock
option with a value other than none, you must have the Lock permission set to Allow. Additionally, you must
own the workspace or have the global Administer workspaces permission set to Allow. For more information,
see Permissions and groups reference.
Parameters
ARGUMENT DESCRIPTION
OPTION DESCRIPTION
/lock Prevents other users from checking in or checking out the
specified items. For more information, see Understanding
Lock Types.
Lock Options:
None
Default. No lock is applied. If you have placed a
lock on the specified file, this option removes it. It
does not remove a lock placed by someone else.
Checkin
Other users can check out the specified items but
they cannot check in revisions to locked files until
you release the lock by performing a check-in. If
any other users have locked any one of the
specified items, the lock operation fails.
Checkout
Prevents other users from checking in or checking
out any one of the specified items until you
release the lock by performing a check-in. If any
other users have locked any one of the specified
items, the lock operation fails.
/recursive Deletes all files and/or folders and subfolders that match
the itemspec from the specified directory.
tf delete folder1\folder2 /recursive (where
folder1\folder2 exists and is a directory) deletes all
the files and subdirectories contained by
folder1\folder2 and folder1\folder2 itself.
tf delete folder1\folder2\filespec /recursive
deletes all files and subdirectories matching
filespec contained in folder1\folder2 and each of
its subdirectories, as well as all files and
subdirectories contained within any directory that
matches the filespec.
For example, in a workspace containing:
Folder1\AVeryLongDirectoryName (with some files
inside) and
Folder1\Folder2\AVeryImportantFile.txt
tf delete 'Folder1\AVer' /recursive
deletes
folder1\folder2\NeverDelete\AVeryImportantFile.tx
t because it matches the wildcard character.
Remarks
The delete command records a pending change of type "delete" in your workspace for the items that you have
specified. When you commit a pending change of type "delete" to the Team Foundation version control server by
using the** checkin** command, Team Foundation removes the item from the Team Foundation version control
server but does not delete it permanently. You can locate deleted items in the Team Foundation version control
server by using the Dir Command and you can restore deleted items using the Undelete Command.
If you have deleted an item in your workspace but have not checked in the change, you can restore the item to
your workspace and remove the deletion from your list of pending changes using the Undo Command.
You cannot delete an item for which another pending change exists. For example, a checked out file cannot be
deleted. To delete such items, you must undo the current pending change using the undo command.
When you check in a pending deletion, Team Foundation marks the file as deleted in the Team Foundation version
control server. Subsequently running a get of the item from other workspaces (either by you or other users)
deletes the item from those workspaces.
When your itemspec specifies a folder, Team Foundation deletes all its files and subfolders and the files they
contain, by default.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example deletes 314.cs on disk in the specified local workspace folder and then, when you check in
the change, removes 314.c from the version control system non-permanently.
See Also
Tasks
Move, Rename, and Delete Version-Controlled Files and Folders
Reference
Undelete Command
Undo Command
Dir Command
Other Resources
Tf Command-Line Utility Commands
Properties Command
5/31/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Displays information about items under version control.
Required Permissions
To use the properties command, you must have the Read permission set to Allow for all specified files and
folders. For more information, see Permissions and groups reference.
Parameters
ARGUMENT DESCRIPTION
TeamProjectCollectionUrl The URL of the project collection that contains the items
for which you want to display properties (for example,
http://myserver:8080/tfs/DefaultCollection).
Itemspec Identifies the files and folders that are specified for
property retrieval.
For more information about how Visual Studio Team
Foundation Server parses itemspecs to determine which
items are within scope, see Command-Line Options.
Note: You can specify more than one Itemspec argument.
OPTION DESCRIPTION
/version Specifies the version of the file to open for viewing the
properties on.
OPTION DESCRIPTION
Remarks
The properties command displays several pieces of information about a version-controlled item. Local and server
information is listed separately.
Local path Indicates the local path of the workspace folder for the
specified item.
Changeset Indicates the version number of the file or folder that was
last retrieved to the current workspace using the Get
Command.
Server path Indicates the full path of the item on the version control
server.
File Type Displays the file type encoding. For example, Windows-
1252.
For links to other Team Foundation commands that describe the items on the server and the workspaces that map
to the server, see Informational Commands.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example displays properties information about the file 314.cs.
The following example displays the properties of the working folder c:\projects\objects.
See Also
Tasks
View Version Control File and Folder Properties
Reference
Command-Line Syntax (Version Control)
Permission Command
Status Command
History Command
Changeset Command
Shelvesets Command
Concepts
Informational Commands
Other Resources
Tf Command-Line Utility Commands
Rename Command (Team Foundation Version
Control)
5/31/2019 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
The rename command changes the name or the path of a file or folder. You can use the rename command or the
aliases move or ren, to move a file or folder to a new location.
Note: The results of this command are not reflected in the Team Foundation version control server until you
perform a check-in operation. For more information, see Check In Pending Changes.
Required Permissions
To use the rename command, you have the Check out permission set to Allow. For more information, see
Permissions and groups reference.
Parameters
Argument
Description
olditem
The original name and path of the file or folder that is to be renamed. You can specify a local workspace path such
as C:\myfiles\314.cs or a Team Foundation version control server path such as $/myfiles/314.cs.
newitem
The new name of the file or folder. You can use this to specify a different local or a Team Foundation version
control server path location.
username
Provides a value to the /login option. You can specify a username value as either DOMAIN\UserName or
UserName.
OPTION DESCRIPTION
/lock Include this option to prevent other users from checking
in or checking out the specified items. If this option is not
specified, the existing lock status of the item is not
changed. For more information, see Understanding Lock
Types.
Lock Options:
None No lock is applied.
Checkin Other users can check out the specified
items but they cannot check in revisions to locked
files until you release the lock by performing a
check-in. If any other users have locked any one of
the specified items, the lock operation fails.
Checkout Prevents other users from checking in
or checking out any one of the specified items
until you release the lock by performing a check-
in. If any other users have locked any one of the
specified items, the lock operation fails.
Remarks
You can use the rename command of the tf command-line utility to move or rename a version-controlled item in
your workspace. Use the rename command to move multiple files by specifying wildcard characters. The ability to
rename multiple version-controlled files or folders, is only available from the command-line.
Use Rename to do the following:
Rename the olditem to the newitem, such as tf rename 314.cs 315.cs .
Move the olditem to a new location in the Team Foundation version control server by providing a newitem
whose path differs from that of the olditem, such as ** ** tf rename 314.cs ..\\newdir\\314.cs .
If you provide a newitem that specifies a non-existent folder, the rename command creates the destination folder.
If newitem is a folder, olditem becomes a child of newitem.
You cannot rename an item if:
You have already deleted it before it was checked in to the same workspace.
The new name already exists in the Team Foundation version control server and is not a folder.
You have already added, branched, or renamed the pending check-in of the item.
The item is mapped in the workspace but not available on the local disk.
The item is cloaked.
You can rename an item for which another file of the same name has been added pending check-in but you cannot
rename an item that has been branched but not yet checked in. When you rename a file that has pending edits, the
edits are preserved.
An item that is explicitly mapped cannot be renamed without first changing the mapping. For example, if there is a
working folder mapping of $/ProjectX/MyApp to c:\MyApp, you cannot rename MyApp. You can rename items
under MyApp but not MyApp itself.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example changes the name of 314.c to 1254.c.
The following example renames 314.c to 1254.c and moves it to the newdir folder.
The following example changes the name of Form1.vb to MainPage.vb and applies a lock to it.
See Also
Tasks
Move, Rename, and Delete Version-Controlled Files and Folders
Reference
Command-Line Syntax (Version Control)
Add Command
Delete Command (Team Foundation Version Control)
Get Command
Concepts
Understanding Lock Types
Pending Changes
Other Resources
Tf Command-Line Utility Commands
Shelve Command
5/31/2019 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Stores a set of pending changes, together with pending check-in notes, a comment, and a list of associated work
items on the server that is running Visual Studio Team Foundation Server without actually checking them into
the version control server.
Required Permissions
If you want to use the shelve command to delete a shelveset, you must be a shelveset owner, or your
Administer shelved changes permission must be set to Allow. For more information, see Permissions and
groups reference.
Parameters
ARGUMENT DESCRIPTION
commentfile Specifies a file system path of a file from which comments for
the shelveset should be read.
TeamProjectCollectionUrl The URL of the project collection that contains the files or
folders that you want to shelve (for example,
http://myserver:8080/tfs/DefaultCollection/).
OPTION DESCRIPTION
/replace Replaces the existing shelveset with the same name and
owner as the one that you specify.
/delete Deletes the specified shelveset. Only the /server option may
be combined with this option. If you do not include the
/noprompt option, a confirmation message appears when
the /delete option is specified.
Remarks
The shelve command of the tf command-line utility backs up pending changes, a list of associated work items,
in-progress check-in notes, and comments in a shelveset on the Team Foundation Server. A *shelveset *is much
like a changeset that is not committed to the server. Like a changeset, a shelveset can be retrieved from the
server into a local workspace by any user who has sufficient permissions.
Shelving is an alternative to checking in pending changes that have not been tested sufficiently. Use shelving
when you want to interrupt you work:
Share a set of local working files together with another developer or tester without checking in your
changes to the version control server.
Set aside a group of pending changes temporarily without checking them in so that you can instead work
on a higher priority issue. After you complete work on the high priority task, you can restore your shelved
changes using the Unshelve Command.
If you include the /move option, the shelve command rolls back all shelved file revisions to their base
workspace versions that is the last version retrieved from the server to the current workspace. Specifically, the
/move option makes sure that for all the items that you shelve:
Uses Undo to undo the changes that were shelved. The files that were pending additions are deleted
from the workspace.
The base workspace versions of all files for which pending editions exist are retrieved from the server into
the current workspace.
All items in the current workspace are marked read-only.
If you include the /delete option, Team Foundation permanently removes the specified shelveset from the Team
Foundation server.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example creates a new shelveset on the Team Foundation Server called Reflector_BuddyTest,
assigns ownership to the user Hans, then returns all items in the current workspace to the latest version
downloaded during the last get operation, and a sets a read-only state.
The following example deletes the existing shelveset, "new -feature" from the server, creates a new shelveset by
that name, and retains all pending changes in the current workspace.
The following example creates a shelveset named HelloWorld_TestMe that includes all pending changes to all .cs
files in the C:\projects working folder and its subfolders.
See Also
Tasks
Shelve and Unshelve Pending Changes
Reference
Command-Line Syntax (Version Control)
Checkin Command
Changeset Command
Unshelve Command
Concepts
Working with Shelvesets
Pending Changes
Other Resources
Tf Command-Line Utility Commands
Unshelve Command
5/31/2019 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Restores shelved file revisions, check-in notes, comments, and work item associations to the current workspace or
removes an existing shelveset from the server.
Required Permissions
To use the unshelve command, you must have the Read permission set to Allow, and you must have the Check
out permission for the items in the shelveset set to Allow. Additionally, to delete a shelveset, you must be its
owner or have the Administer shelved changes global permission set to Allow. For more information, see
Permissions and groups reference.
Parameters
Argument
Description
shelvesetname
The name of the shelveset to restore.
ownername
The name of the shelveset owner.
Itemspec
Identifies the file or folder revisions to unshelve into the current workspace. If this parameter is not included, all
pending changes in the specified shelveset are unshelved, by default. Server paths are not allowed.
For more information about how Team Foundation parses itemspecs to determine which items are within scope,
see Command-Line Options.
>Note:
>You can specify more than one Itemspec argument.
username
Provides a value to the /login option. You can specify a username value as either DOMAIN\UserName or
UserName</i.
OPTION DESCRIPTION
/move Deletes the specified shelveset from the server for Team
Foundation version control upon successful completion of
the unshelve operation. This option cannot be combined
with an itemspec.
You can also delete a shelveset using the shelve
command.
Remarks
The unshelve command of the tf command-line utility retrieves either all shelved file revisions or a defined
subset of all shelved file revisions from the Team Foundation server into the current workspace.
To unshelve an item, there must be no pending revisions against it in the destination workspace.
When you unshelve a shelveset, Team Foundation restores each shelved revision into the destination workspace
as a pending change as long as the revision does not conflict with a change that was already pending in the
workspace. For more details about what happens during the unshelve process, see Working with Shelvesets.
You can use the unshelve command to restore individual file revisions from a shelveset to your workspace. You
should run get after unshelving to reconcile any changes checked into the server since the shelveset was created.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Recycle Shelved Changes
If you want to integrate shelved revisions into your current workspace in order to make ongoing revisions,
unshelve the desired shelveset. As a best practice, get the latest version of your version-controlled files after
unshelving as well.
Unshelve and Review Another User's Code
You can also unshelve a shelveset in order to review changes from another user's workspace. To unshelve for this
reason, you have two options.
If the shelved items and the items with which they are related have not been revised, or have only been
revised lightly since the shelveset was created, you can retrieve the base version of all related items from
the shelveset owner's workspace. To do this, use some variation of the following command:
tf get \* /version;Wworkspacename , where workspacename is the name of the workspace from which the
other user created the shelveset.
If a significant amount of time has passed or if multiple revisions have been in the workspace since the
shelveset was created, retrieve the version of all related items from the server as of the date and time when
the shelveset was created.
You can unshelve another user's shelved change by appending the username to the shelveset name. However,
you can only remove a shelveset from the Team Foundation Server that was created by another user if you have
the AdminShelvedChangesets permission.
If you attempt to unshelve an item for which a pending change exists in the destination workspace, Team
Foundation does not merge differences between the items and does not retrieve the revision into your workspace.
You can delete a shelveset by using tf shelve /delete . For more information, see Shelve Command. In order to
automatically delete a shelveset after unshelving the entire shelveset, use tf unshelve /move .
Examples
The following example opens the Unshelve dialog box so that you can find and unshelve a shelveset into the
current workspace. You also have an option in the dialog box to have the shelveset deleted when the unshelve
operation completes.
c:\>tf unshelve
The following example unshelves the shelveset buddytest_1256 into the current workspace and removes it from
Team Foundation Server.
See Also
Tasks
Shelve and Unshelve Pending Changes
Reference
Command-Line Syntax (Version Control)
Shelve Command
Changeset Command
Concepts
Working with Shelvesets
Other Resources
Tf Command-Line Utility Commands
Branch Command
5/31/2019 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
The branch command copies an item or set of items, including metadata and version control history, from one
location to another in the Team Foundation version control server and in the local workspace.
NOTE
The results of this command are not reflected in the Team Foundation version control server until you perform a check-in
operation. For more information, see Check In Pending Changes.
Required Permissions
To use the branch command, you must have the Read permission for the source item and the Check out and
Merge permissions for the target folder set to Allow. For more information, see Permissions and groups
reference.
Parameters
ARGUMENT DESCRIPTION
olditem Specifies the name of the source file or folder being branched.
The olditem may also contain version information in the
format item;version.
@commentfile Specifies the path of a file that contains the comment that is
used for the branch.
OPTION DESCRIPTION
/version The version of the item at which you want to create the
branch. You can specify a version by:
Date/time (D10/20/2005)
Changeset number (C1256)
Label (Lmylabel)
Latest version (T)
Workspace (Wworkspacename)
If no version is provided, Team Foundation uses the
following logic to decide which version of the item to
copy to the new branch:
If a Team Foundation version control server path
is specified, then Team Foundation branches the
item at the latest Team Foundation version
control server version. For example, tf branch
$/projects/help.cs uses the server version.
If a local path is specified for the source, Team
Foundation uses the local, workspace version to
create the new branch. For example, tf branch
C:\314.cs uses the local workspace version.
If you branch a file whose workspace version is older
than the latest version in the Team Foundation version
control server, the file is branched at the older version.
/lock Prevents other users from checking in or checking out
items until you check in your pending branch and
associated changes. For more information, see
Understanding Lock Types.
Lock Options:
None
Default. No lock is applied. If a lock exists on the
file that you are creating a branch for, this option
removes it.
Checkin
Other users can check out the specified items but
they cannot check in revisions to locked files until
you release the lock by performing a check-in. If
any other users have locked any one of the
specified items, the lock operation fails.
Checkout
Prevents other users from checking in or checking
out any one of the specified items until you
release the lock by performing a check-in. If any
other users have locked any one of the specified
items, the lock operation fails.
Note:
You can prevent items, such as the contents of an /images
folder, from being retrieved to your workspace during
recursive Get and Get Latest operations by cloaking a
workspace folder. For more information, see Workfold
Command.
Remarks
If you specify a local path such as c:\00101 but do not specify a versionspec, Team Foundation uses the local
workspace version as the basis for creating the new branch.
However, if you specify a server path such as $/00101/*.cs and do not specify a versionspec, Team Foundation
uses the latest Team Foundation version control server version as the basis for creating the new branch instead.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example creates a branch file that contains the latest workspace version of 314.cs, names it
"314_branch", and saves it to the current directory on disk and also to the Team Foundation version control
server folder to which it maps.
The following example copies all the files without pending edits in the workspace version of 314.cs from its
current Team Foundation version control server folder into the testdata Team Foundation version control server
folder and from the current directory on disk to the working folder that maps to the testdata Team Foundation
version control server folder.
The following example copies all the files without pending edits in the current workspace version of the testfiles
folder and the files it contains for all items from its current Team Foundation version control server folder into
the testfiles_branch Team Foundation version control server folder and from c:\testfiles into the local folder that
maps to the testfiles_branch Team Foundation version control server folder.
The following example creates a branch of 314.cs as it existed in changeset #4 for the file. In the working folder
on disk, as in the Team Foundation version control server, a branch file titled csharp_branch is created.
The following example creates a new branch of 314.cs as it was on 12/12/03. In the working folder on disk as in
the Team Foundation version control server, a branch file titled 314_branch is created.
See Also
Tasks
Branch Folders and Files
Reference
Branches Command
Merge Command
Concepts
Working with Changesets
Other Resources
Tf Command-Line Utility Commands
Branches Command
5/31/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Displays the history of a branch for a specified file or folder.
Required Permissions
To use the branches command, your Read permission must be set to Allow for the item and any branches to
view their history. For more information, see Permissions and groups reference.
Parameters
Argument
Description
Itemspec
Identifies the file or folder that contains the branch you want to examine. For more information about how Team
Foundation parses itemspecs to determine which items are within scope, see Command-Line Options.
Versionspec
Provides a value for the /version option. For more information about how Team Foundation parses a version
specification to determine which items are within its scope, see Command-Line Syntax (Version Control).
TeamProjectCollectionUrl
The URL of the project collection that contains a file or folder in a branch for which you want to display the history
(for example, http://myserver:8080/tfs/DefaultCollection).
username
Provides a value to the /login option. You can specify a username value as either Domain\UserName or
UserName.
OPTION DESCRIPTION
/version Specifies the version for the path. This option is rarely
used.
## Remarks The branches command tells you when an item has been the source or destination of a branch operation.
The output displays the parent branch for each version.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example displays branch history for the version-controlled file C:\314.cs.
The following example displays branch history for the header.h item in the Team Foundation version control
server.
The following example displays the branch history of the folder $/rel30/math.
The following example displays the branch history for WindowsApplication13-branch. The results indicate the
history for the specified branch by using angle brackets.
See Also
Reference
Branch Command
Merges Command
Concepts
Informational Commands
Other Resources
Tf Command-Line Utility Commands
Branching and Merging
Changeset Command
5/31/2019 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Displays information about and lets you change the attributes, such as comments and check-in notes, that are
associated with a changeset.
Required Permissions
To use the changeset command you must have the Read permission set to Allow for any files or folders in the
changeset for which you wish to display full information. The only users who can modify the notes and
comments that are associated with a changeset are the users who created the changeset or a user who has the
Revise other user's changes global permission. For more information, see Permissions and groups reference.
tf changeset [/comment:("comment"|@commentfile)]
[/notes:("NoteFieldName"="NoteFieldValue"|@notefile)] [/noprompt][/collection:TeamProjectCollectionUrl]]
[changesetnumber | /latest][/login:username,[password]]
Parameters
ARGUMENT DESCRIPTION
NoteFieldName=NoteFieldValue Sets the value of the check-in note field. You can provide
multiple, semicolon-separated "field=value" expressions.
@notefile Provides the path of a file on disk that contains check-in note
field names and values in the format of "field=value" with one
per line.
username Provides a value to the /user option. You can specify this
argument as either Domain*UserName* or UserName.
OPTION DESCRIPTION
Remarks
A changeset is a set of file and folder revisions that were committed to the Team Foundation version control
server as part of the same check-in event. For more information, see Working with Changesets.
You can use the changeset command to view the attributes of a changeset and modify its properties. You can
use the History command to determine which changeset you want to obtain information about. For more
information, see History Command.
For links to other Team Foundation commands that provide additional information about the items in your Team
Foundation version control server and all the workspaces that map to it, see Informational Commands.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example Displays detailed information about changeset 8675309 in an editable format in the
**Changeset **dialog box and replaces the existing comment with "This is a new comment."
After you press ENTER, the Details for Changeset <changeset number> - Source Files dialog box appears.
Click Save to associate the comment with the changeset.
The following example provides two check-in notes to associate with the changeset.
The following example provides two check-in notes that include spaces in the values and names to associate with
the changeset.
The following example associates the check-in notes included in the file notes.txt with the changeset 8675309.
field2=value that
spans multiple
lines;
field3 = value3;
The following example replaces the existing comment for changeset 8675309 and displays information about the
changeset in the Command Prompt window. The example does not start the **Changeset **dialog box.
The following example displays non-editable information about changeset 8675309 in the Command Prompt
window.
Sample output:
Changeset: 8675309
User: DOMAIN\JohnG
Date: 01/21/2004 21:03:45
Comment: This check-in fixes issues in several features. I also refactored some items in buf.c into a new
file named bif.c because buf.c was too hard to parse.
Items:
$/baz/proj/bif.c Added
$/baz/proj/buf.c Modified, Renamed
Work Items:
34527 The "Access Denied" message is not descriptive enough.
35628 The UI flickers when I press the '8', 'y', 'Ctrl', and 'End' buttons at the same time.
Check-in Notes:
Code Reviewer: ShellM
Performance Reviewer: ShellM
Security Reviewer: ShellM
See Also
Reference
Checkin Command
Checkout and Edit Commands
Shelve Command
History Command
Configure Command
Concepts
Working with Changesets
Other Resources
Tf Command-Line Utility Commands
Configure Command
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Enables an administrator to view and change the following configuration settings for a project in the Source
Control Settings dialog box:
Check-out settings
Check-in policies
Check-in notes
Required Permissions
To use the configure command, you must have the Edit server-level information permission set to Allow. For
more information, see Permissions and groups reference.
Parameters
ARGUMENT DESCRIPTION
TeamProjectCollectionUrl The URL of the project collection that contains the project
that you specified (for example,
http://myserver:8080/tfs/DefaultCollection).
OPTION DESCRIPTION
Remarks
You can manage the following project settings using the configure command:
Check-out settings can be used to determine whether multiple users can edit files at the same time. Also,
they can be used to configure the get latest on check-out behavior.
Check-in policies provide controls that are invoked at check-in time, to make sure that defined criteria are
met before a user checks in pending changes.
Check-in notes define custom fields into which users provide information during the check-in process.
Check-in notes can be either required or optional.
The settings are configured in the Source Control Settings dialog box which appears after you run the
configure command. When you complete your changes, click OK to save them to the server.
For more information about these settings, see Walkthrough: Customizing Checkin Policies and Notes.
For links to other Team Foundation commands that provide additional information about the items in your Team
Foundation version control server and all the workspaces that map to it, see Informational Commands.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example displays the Source Control Settings dialog box in which you can examine and modify
the project settings of the workspace for the c:\projects folder.
c:\projects>tf configure
The following example displays the myproj project settings in the project collection at
http://myserver:8080/tfs/DefaultCollection.
See Also
Tasks
Configure Check-Out Settings
Concepts
Managing File Types
Other Resources
Tf Command-Line Utility Commands
Destroy Command (Team Foundation Version
Control)
5/31/2019 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Use the tf destroy command to destroy, or permanently delete, version-controlled files from Team Foundation
version control.
The destroy action cannot be reversed. You must not destroy files that are still needed. Sometimes you have to
clean up version control systems. For example, if some files are infected with a computer virus, you have to
remove them permanently from version control.
Before you run tf destroy without the /keephistory option, we recommend that you first delete the files you
want to destroy. For more information, see Delete Files and Folders from Version Control.
After you delete the files you can synchronize the Team Foundation warehouse. Otherwise, the warehouse will not
be synchronized with the destroyed items.
Required Permissions
To use the destroy command, you must belong to the Team Foundation Administrators security group. For
more information, see Permissions and groups reference.
Parameters
ARGUMENT DESCRIPTION
OPTION DESCRIPTION
Remarks
When you use tf destroy to destroy version-control files, the application tier of Team Foundation Server receives
the destroy request and checks to see whether you are a member of the Team Foundation Administrators
security group. If you are not a member, the system displays an error-message dialog box that tells you that you
do not have sufficient permissions to perform the operation.
After the system verifies your permissions, it runs the destroy command. This command deletes all file references,
shelvesets, and pending changes. The actual destruction of files, which is a permanent deletion, happens the next
time that the content that is no longer referenced by Team Foundation Server is cleaned up. You can also specify
the /startcleanup option to clean up the files immediately after tf destroy runs.
If you run tf destroy without specifying /i and /preview, the system displays a console Yes or No prompt for
each filespec value. Otherwise, you can specify Yes to all. If you do not specify /keephistory, you are prompted
by an interactive text that warns of pending changes, if they exist. The interactive text points to /preview if you
want more information about the changes. If you specify /keephistory, you are also prompted by Yes, No, or All
text. If you select Yes or All, the destruction process starts, and the server paths to the destroyed items appear in
the Command Prompt window.
Destroyed: <serverItem1>
Destroyed: <serverItem2>
Destroyed: ...
If you specified the versionspec value as a tip, the server paths displayed in the Command Prompt window
include deletion IDs. For example, X123 might appear in the Command Prompt window.
If you use the /preview option, the files are not destroyed, but the command-line text displays the files that would
be destroyed. For example, if, at the command-line, you type tf destroy /preview
$/Test1/MyProject/MyProject/Program.cs, the command window displays this text:
Destroyed: $/Test1/MyProject/MyProject/Program.cs
However, the file is actually not destroyed because you used the /preview option.
For more information about how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Effects of /keephistory on Other Version Control Operations
If you specify the /keephistory option to retain the history of destroyed files, the files are treated as destroyed by
the following Team Foundation version control operations:
**Change content **If you try to change the content of a destroyed file, for example edit or branch, the
system issues an error message that states the content has been destroyed.
**Branch, merge, or unshelve **If you try to branch, merge, or unshelve destroyed items, the system issues
an error message that states the content of the items has been destroyed.
Destroying Previously Deleted Items
If an item has already been deleted, a deletion ID is attached to it and results in a filename change.
Effects of TF DESTROY on TFVC repo Code Search
Code Search does not handle TF DESTROY notifications and so using TF DESTROY for TFVC repos will not
automatically delete files in the Search index. As a result, these files appear in the code search results. To avoid
these ghost files scenario, users are recommended to delete files before TF DESTROY operation.
Examples
Description
The following example permanently deletes the file a.cs.
Code
Description
The following example deletes a folder, aFolder, type at the command line:
Code
Description
To destroy the deleted item, aFolder, you must type at the command line:
Code
tf destroy $/MyTeamProject/sFolder;x123
See Also
Tasks
Destroy Version Controlled Files
Concepts
Operations Available Only From the Command-Line (Team Foundation Version Control)
Other Resources
Tf Command-Line Utility Commands
Difference Command
5/31/2019 • 8 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Compares, and if it is possible, displays differences between two files, files in two folders, or a shelveset and a
local or a server file.
Required Permissions
To use the difference command, you must have the Read permission for all specified items set to Allow. For
more information, see Permissions and groups reference.
tf diff[erence] [/shelveset:shelvesetname[;shelvesetowner]]
shelveset_itemspec [/type:filetype]
[/format: format] [/ignorespace] [/ignoreeol] [/ignorecase]
[/recursive] [/options] [/noprompt][/login:username,[password]]
tf diff[erence] /configure
Parameters
ARGUMENT DESCRIPTION
Filetype Provides a value for the /type option. You can specify
"binary" or "text," and a codepage number or the friendly
name for a codepage.
/recursive Compares the differences between the current folder and all
its subfolders.
/configure Invokes the Configure User Tools dialog box. This tool is
available from the Visual Studio user interface. For more
information, see Associate a File Type with a Difference Tool.
Remarks
Note:
You can type tf diff or tf difference at the command line to run this command.
You can use the difference command to compare and if it is possible, display differences between:
Two different files or two versions of the same file.
One or more of the items in a folder.
One, some, or all the items in a shelveset on the Team Foundation Server.
You can use the difference command to compare both versioned and non-versioned files.
Team Foundation categorizes all files by type. Text files can be merged and compared, side by side and line by
line, as long as both files have the same encoding. If you want to compare two files whose encodings are not the
same, you can temporarily mask, or override the encoding property for a file by using the /type option. Binary
files can be compared but cannot be merged. When you pass one or more binary files to the difference
command, Team Foundation indicates whether differences exist between it and the item to which it is being
compared. For more information about how Team Foundation differentiates between and treats files of disparate
types, see Managing File Types.
If you specify two file names, the two files are compared. Instead of using the /version flag, you can specify
versions by appending a semicolon and version specifier to the end of each file name.
If you pass only one itemspec to the difference command:
If do not provide a versionspec, your current workspace version of the item is compared to the base
workspace version, by default. For example, tf difference header.h compares the current version of
header.h to the version upon which header.h is based.
If you include a versionspec in your itemspec such as , tf difference header.h;LBeta1, Team Foundation
compares that version to your current workspace version on disk.
If you specify a range of versions such as /version:C1~C4, the versions of the file at the two end points of
the range are compared.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Output Format types
The format parameter, used with the /format option, specifies many different output formats. The available
output types are
Visual
Visual format type opens an external difference application. By default diffmerge.exe is launched.
Brief
Brief format prints whether the files being compared differ.
Context
Context format provides lines of context for the differences in the files. This format is derived from the
UNIX based diff -c output format.
RCS
RCS format is similar to /format:unix, except context lines are not supplied.
No special handing for a missing end of line marker at the end of the file is provided.
SS
SS is default difference output format for Visual SourceSafe. For more information, see "Diff (Command
Line)" at the Microsoft Web site (http://go.microsoft.com/fwlink/?LinkId=99139).
SS_SideBySide
SS_SideBySide is the default side-by-side output format for Visual SourceSafe.
SS_Unix
SS_Unix is similar to the /format:unix output format, but /format:ss_unix includes context lines and
/format:unix does not.
Unified
Unified format is derived from the UNIX based diff -u output format. /format:context repeats identical
context lines between the difference strings although /format:unified does not.
Unified format produces a new unified difference string (@@ ... @@) line only when the distance to the
next difference string is larger than the number of context lines.
Unix
This output type is derived from the UNIX based diff command output format.
The Unix output format is constructed in the following way:
<metadataline>
"< " line prefix for lines from the first file
"---" line
"> " line prefix for lines from the second file
Examples
The following example displays the differences between the local version of 314.cs and the workspace
version of 314.cs that is the version of the file that was checked out from the Team Foundation version
control server.
c:\projects>tf difference 314.cs
The following example displays all files that have been changed in the src folder. Does not display files that have
been changed in subfolders of src.
The following example displays the differences between changeset 3 and changeset 8 of 1254.cs.
c:\projects>tf difference /version:C3~C8 1254.cs
The following examples display the differences between the version of 314.cs that belong to the label "release"
and the version that belongs to changeset 3200.
-or-
The following example displays the difference between the versions of e271.cs that a user named Nadia shelved
in shelveset PeerCodeReview8 and the base shelveset version that is the version upon which she based her
changes. Also displays the types of changes pending against e271.cs when Nadia shelved.
The following example displays the differences between all files in the PeerCodeReview2 shelveset and the base
shelveset version of those files.
See Also
Reference
Merge Command
Checkin Command
Shelvesets Command
Concepts
Managing File Types
Other Resources
Tf Command-Line Utility Commands
Comparing Folders and Files
Dir Command
5/31/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
The dir command displays all or some of the contents of the server for Team Foundation version control.
Required Permissions
To use the dir command, you must have Read permission set to Allow. For more information, see Permissions
and groups reference.
Parameters
Argument
Description
itemspec
Identifies the file or folder to return information about. For more information about how Team Foundation parses
itemspecs to determine which items are within scope, see Command-Line Options.
Note
You can specify more than one Itemspec argument.
versionspec
The user-provided value for the /version option. For more information about how Team Foundation parses a
version specification to determine which items are within its scope, see Command-Line Syntax (Version Control).
username
Provides a value to the /login option. You can specify a username value as either DOMAIN\UserName or
UserName.
TeamProjectCollectionUrl
The URL of the project collection that contains one or more files or folders about which you want to display
information (for example, http://myserver:8080/tfs/DefaultCollection/).
OPTION DESCRIPTION
/version Specifies that Team Foundation should only show files and
folders of a certain version.
## Remarks The dir command operates on the Team Foundation version control server copies of files, not the local
copies. The command uses the local mapped folder to locate the appropriate Team Foundation version control server
path. You use this command to explore the Team Foundation version control server and identify files you may have to
obtain.
For links to other Team Foundation commands that provide additional information about items in your Team
Foundation version control server and the workspaces that map to it, see Informational Commands.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example displays a list of files, folders, subfolders, and the files therein in the Team Foundation
version control server folder to which c:\projects maps. The number of items is also listed. For more information
about how to view and edit working folder mappings, see Workspace Command and Workfold Command.
The following example displays all Team Foundation version control server files at that path. The "314dir"
subfolder does not have to exist in the local folder.
The following example displays the version of files labeled "My label" in that Team Foundation version control
server path. The "314dir" subfolder does not have to exist in the local folder.
The following example displays all folders in the root of the Team Foundation version control server. The local
working folder is ignored because $/ denotes a Team Foundation version control server path.
The following example lists every file and folder in the Team Foundation version control server.
See Also
Tasks
Add and Remove a Working Folder in a Workspace
Reference
Workspace Command
Workfold Command
Concepts
Informational Commands
Other Resources
Tf Command-Line Utility Commands
Folderdiff Command
5/31/2019 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Use the folderdiff command to display and compare a visual representation of the differences between files in
two server folders, in a server folder and a local folder, or in two local folders.
Required Permissions
To use the folderdiff command, you must have the Read permission set to Allow. For more information, see
Permissions and groups reference.
Parameters
Argument
Description
sourcePath
The local or server path that is the source path in the compare operation. If this argument is not supplied and
targetPath is the local mapped path, sourcePath is the server path that is mapped to it.
targetPath
The local or server path that is the target path in the compare operation.
filter
Specifies a semicolon delimited list of inclusion and exclusion filter masks for the /filter option. Default is "*"
(include all). The Remarks section in this topic includes a detailed description of filters and masks.
TeamProjectCollectionUrl
The URL of the project collection that contains the files for which you want to display and compare the differences
(for example, http://myserver:8080/tfs/DefaultCollection).
username
Provides a value to the /login option. You can specify a username value as either DOMAIN\UserName or
UserName.
OPTION DESCRIPTION
/recursive Optional. Specifies that the two folders are fully compared
recursively.
/noprompt Optional. tf folderdiff runs without displaying user
interface. The output is displayed in the Command
Prompt window instead.
/filterLocalPathsOnly Optional. Specifies that only the local paths will be filtered,
unless the corresponding server path exists.
Remarks
The Command Prompt window displays the output if you specify /noprompt. Otherwise, the Folder Difference
window displays the output. When the system compares the local mapped folder to the server folder to which it is
mapped, the output in the Folder Difference window includes a list of pending changes. Also, the output in the
Folder Difference window tells you whether the local folder contains the latest copy or not.
The output displayed in the Command Prompt window lists all the files in the folders in the following five sections:
Items that exist only in the server folder.
Items that exist only in the local folder.
Items that have different contents.
Items that have identical contents (you must specify the same argument with the /view option).
Summary.
File and Folder Filters
A filter is an ordered list of name masks used to match the name of files and folders to be compared. Each mask
can contain the wildcard characters question mark (?) and asterisk (*). '?' matches exactly one character and '*'
matches zero or more characters. The masks in a filter are delimited by semicolons (;). Folder masks must end in
backslash (\). To specify an exclusion mask, prefix the mask with an exclamation mark (!).
The filter is applied to the file and folder names using the following rules:
When both file and folder masks are specified together in a filter, the file masks are separated into a file
mask list and the folder masks are separated into the folder mask list. File masks are applied only to file
names. Folder masks are applied only to folder names.
When the command matches a file or folder name, it compares the name to each mask in the filter in the
order it was specified. As soon as the name matches a mask, the name is considered to be a match.
If the file masks in the filter contain an inclusion mask, files that do not match any of the file masks are
excluded.
If the file masks in the filter contain only exclusion masks, files that do not match any of the file masks are
included.
If the folder masks in the filter contain an inclusion mask, folders that do not match any of the folder masks
are excluded.
If the folder masks in the filter contain only exclusion masks, folders that do not match any of the folder
masks are included.
The following table lists filter name mask examples.
FILTER DESCRIPTION
*.cs;!objd\;!obj\;!bin\ Matches all C# files except those in objd, obj, or bin folders.
!*.resx;!*.ini;!resources\;!*junk*\ Excludes all .resx and .ini files, all files in the resources folder,
and all files in any folder that has a name that includes the
word junk.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example compares the files in the server folder and a local folder. It organizes the files in the
localFolder recursively and displays the output in the Command Prompt window.
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Displays help on the command line that contains information about syntax for a Team Foundation version control
command.
tf help commandname
Parameters
Argument
Description
commandname
Specifies a Team Foundation command for which to display help about the syntax.
## Remarks If you do not know which command you need, type tf help for a list of all commands.
If you specify the commandname parameter, the command line displays information about the arguments and
options for that command. If the system cannot find a match for the commandname, it searches for aliases and
short names. If it cannot find any matching command, alias, or short name, you will get an error.
The option /? is an alias for help. If you use the /? option together with a command, the system invokes the help
command and it displays information about syntax.
For more information about how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example displays a list of the version control commands.
c:\projects>tf help
The following example displays information about syntax for the workspace command.
The following example also displays the same information about syntax for the workspace command.
c:\projects>tf workspace /?
See Also
Reference
Msdn Command
Other Resources
Tf Command-Line Utility Commands
Label Command (Team Foundation Version Control)
5/31/2019 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Updated: October 2011
Attaches a label to or removes a label from a version of a file or folder in the server for Team Foundation version
control.
Required Permissions
To use the label command, you must have the Label permission set to Allow. To modify or delete labels created
by other users, you must have the Administer labels permission set to Allow. For more information, see
Permissions and groups reference.
Parameters
ARGUMENT DESCRIPTION
Note
You can specify more than one Itemspec argument.
versionspec Provides a value such as c2 for the /version option. For
more information about how Team Foundation parses a
version specification to determine which items are within
its scope, see Command-Line Syntax (Version Control).
OPTION DESCRIPTION
/owner Specifies the name of the user who owns the label.
/recursive Labels all items in the directory that matches your itemspec
and versionspec. Cannot be used with the /delete option.
Remarks
A label is a marker that you can attach to a set of unrelated files and folders in the Team Foundation version
control server. Use the label to simplify their retrieval to a workspace for either development or build purposes.
Therefore, a label is like a changeset or date/time to which and from which you can arbitrarily add and remove
files and folders or change the versions of the items therein. A label is a version specification that can be passed to
the following Team Foundation commands:
Branch Command
Difference Command
Dir Command
Get Command
History Command
Merge Command
View Command
Common types of labels are milestone labels such as "M1," "Beta2," or "Release Candidate 0."
Labels are version-specific, that is, you can only attach a label to one version of a file or folder. Each version of an
item can support multiple labels.
A label is not a versioned object; therefore, the label history of files is not tracked. Additionally, a label operation
does not create a pending change in your workspace. When you issue the label command, the update is
immediately reflected in the Team Foundation version control server.
For more information about how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Removing and Deleting Labels
You can use the Unlabel Command to remove a label from a file or folder. Alternatively, you can delete a label
from the system using the tf label /delete command.
For information about an existing label that includes a list of the items to which the label has been attached, its
comment, scope, and owner, see Labels Command.
Managing Overloaded Labels
Label names must be unique throughout a specified scope. When you add a label, you reserve the use of that
label name at or under the specified or implied scope. The default value for the @scope parameter is the project,
for example, $/TeamProject1.
If another team or user adds a common label such as "M3" to a set of version-controlled files in a different part of
the Team Foundation version control server, you can apply the M3 label to version-controlled files in your project
as long as the root project folders are in different directories. For example, if files in the $/math directory are
labeled "M3," you can apply the "M3" to files in your $/projects directory.
To get, remove a label, or otherwise manage your M3-labeled items, you should specify the @scope parameter to
tell Team Foundation which M3 label you want to work with.
You can prevent other users from "overloading" a label such as "M3" in different parts of the Team Foundation
version control server by either creating your label at the root ($/) of the Team Foundation version control server
or by adjusting Label permissions for certain folders.
Examples
The following example attaches the "goodbuild" label to the workspace version of the "docs" folder and the files
and folders it contains.
The following example attaches the "goodbuild" label to the "docs" folder but not the files and folders the docs
folder contains.
The following example attaches the "goodbuild" label to version 3 of 314.cs in the Team Foundation version
control server.
The following example deletes the "badbuild" label from all items in the Team Foundation version control server.
The following example uses the scope option to apply a label to 314.cs.
See Also
Reference
Command-Line Syntax (Version Control)
Labels Command
Unlabel Command
Concepts
Use Labels to Take a Snapshot of Your Files
Use Labels to Take a Snapshot of Your Files
Other Resources
Tf Command-Line Utility Commands
Change History
DATE HISTORY REASON
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Displays the list of labels in the server for Team Foundation version control.
Required Permissions
To use the labels command, you must have the Read permission set to Allow for all files or folders to which the
specified label is attached. If you have permission to some, but not all the files referenced in the label, partial
results are displayed. For more information, see Permissions and groups reference.
Parameters
ARGUMENT DESCRIPTION
labelname Specifies a string that should be used to filter the list of labels.
If this parameter is omitted, the label name field will not be
filtered.
TeamProjectCollectionUrl The URL of the project collection for which you want to
display the list of labels (for example,
http://myserver:8080/tfs/DefaultCollection).
OPTION DESCRIPTION
/owner Specifies the name of the user who owns the label. By default,
the owner is the person who applies the label.
Examples
The following example displays the list of labels created by user "jasonj."
The following example displays information about "build1033" label and lists the files and folders to which the
label has been applied in the Team Foundation version control server.
The following example displays all labels in the Team Foundation version control server that have a labelname
that begins with "build" and are owned by the account executing the labels command.
See Also
Reference
Command-Line Syntax (Version Control)
Label Command (Team Foundation Version Control)
Unlabel Command
Concepts
Informational Commands
Other Resources
Tf Command-Line Utility Commands
LocalVersions Command
5/31/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Displays the version of one or more items in a workspace.
Required Permissions
To use the localversions command, you must have the Use permission to the workspace. For more information,
see Permissions and groups reference.
tf localversions ItemSpec
[/recursive] [/format:brief|detailed]
[/workspace:WorkspaceName[;WorkspaceOwner]] [/collection:TeamProjectCollectionUrl]
Parameters
ARGUMENT DESCRIPTION
Itemspec Specify either a file or a folder that contains the files for
which you want to display version numbers.
You can specify only a local file or folder. For example,
c:\project1\binder.cs is valid, but $/project1/binder.cs is
not.
Note
You can specify more than one Itemspec argument.
OPTION DESCRIPTION
/format Specify one of the following options to control how the
data returned by this command appears:
Brief
(Default.) Each directory appears only once,
followed by the files that it contains.
Detailed
Each file appears after its full path.
Remarks
When you get or check out a file, you usually download the most current version. However, you may have older
versions of some files in your workspace.
For example, you might have checked out some files and not checked in your work for several weeks. Other
people on your team may have checked in changes to the same files during that time. In this case, the versions of
these files in your workspace would be older than the current versions on your server for Team Foundation
version control. You can use the localversions command to get information about which versions of these files
are in your workspace.
For information about other Team Foundation commands that provide additional information about items in your
server for Team Foundation version control and the workspaces that map to it, see Informational Commands.
For more information about how to find and use the tf command-line utility, see Tf Command-Line Utility
Commands.
Examples
The following example displays the version of the ControllerBase.cs file in the workspace that is mapped to the
c:\\workspaces\\FeatureA\\catalog\\controller folder.
The following example displays the versions of all files (including those in subfolders) in the workspace that is
mapped to the c:\\workspaces\\FeatureA\\catalog\\ folder. Because the /format:detailed option is specified, each
file appears with its full path.
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Locks or unlocks a file or folder to deny or restore the right of users to check out an item for edit into a different
workspace or to check in pending changes to an item from a different workspace.
Required Permissions
To use the lock command, you must have the Lock permission set to Allow. Having the Unlock other user's
changes permission set to Allow is required to remove a lock held by another user if you do not have Write
permission for that user's workspace. For more information, see Permissions and groups reference.
Parameters
ARGUMENT DESCRIPTION
TeamProjectCollectionUrl The URL of the project collection that contains the file or
folder that you want to lock or unlock (for example,
http://myserver:8080/tfs/DefaultCollection).
OPTION DESCRIPTION
/lock Specifies a lock type or removes a lock from an item. For
more information, see Understanding Lock Types.
Lock Options:
None
Removes a lock from an item.
Checkin
Enables an item to be checked out and edited in
all workspaces but prevents users from checking
in changes to the item outside the specified
/workspace until you explicitly release the check-
in lock. If the specified item is locked in any other
workspace, the lock operation fails.
Checkout
Prevents users from checking in or checking out
the specified items until you explicitly release the
lock. If users have locked any one of the specified
items, or if pending changes exists against any
one of the items, the lock operation fails.
Remarks
You can use the lock command to temporarily freeze the Team Foundation version control server version of an
item so that you can check in a pending change without having to resolve any merge conflicts. If you want to
permanently prevent access to an item in the Team Foundation version control server, you should use the
Permission Command instead.
Note:
As a courtesy to your teammates, notify them when you apply a lock to an item, explain why you are doing
this, and estimate when you plan to remove the lock, if you can.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
How to Lock an Item
You can lock an item using the lock command or by specifying a lock option during the commission of several
other commands of the tf command-line utility that includes:
Rename Command (Team Foundation Version Control)
Checkout and Edit Commands
Delete Command (Team Foundation Version Control)
Undelete Command
Merge Command
Branch Command
Add Command
For add and branch, the lock is placed on the namespace where the new item will be created. Locks placed with
rename apply both to the old and new namespaces. For more information, see Lock and Unlock Folders or Files.
Lock Types
Team Foundation provides two types of locks: checkin and checkout.
A check-in lock is less restrictive than a check-out lock. When you apply a check-in lock, users can continue to
make local changes to the item in other workspaces. The changes cannot be checked in until you explicitly
remove the check-in lock from the workspace.
A check-out lock is more restrictive than a check-in lock. When you apply a check-out lock to a version-
controlled file or folder, users can neither check out the file for edit nor check in pre-existing pending changes.
You cannot acquire a check-out lock if there are currently any pending changes to an item.
For more information about when to apply a check-out lock and when to apply a check-in lock, see
Understanding Lock Types.
How Locking Works
If you have a file checked out when you lock it, its status is modified to contain the new lock type. If the files are
not checked out, a "lock" change is added to the set of pending workspace changes. Unlike the checkout
command, lock does not automatically make a file editable.
Locks on folders are implicitly recursive. If you lock a folder, you do not have to lock the files it contains unless
you want to apply the more restrictive check-out lock to a file in a folder that has a check-in lock.
Unlocking an Item
You can unlock a locked item using the none option. Additionally, Team Foundation unlocks an item
automatically when you check in pending changes in the workspace.
You can determine which files are locked in the Team Foundation version control server and by whom the files
were locked using the Status Command.
Examples
The following example prevents other users from checking out 314.cs.
The following example prevents other users from checking in changes to 1256.cs but enables them to check it
out in their workspaces.
The following example prevents other users from pending changes to any items in the src/ folder in the Team
Foundation version control server.
c:\projects>tf lock /lock:checkout $/src
The following example unlocks and makes all files in the src/ Team Foundation version control server folder
available for check-out and check-in by other users.
See Also
Reference
Command-Line Syntax (Version Control)
Checkout and Edit Commands
Status Command
Concepts
Understanding Lock Types
Create a Workspace to Work with your Project
Other Resources
Tf Command-Line Utility Commands
Working with Version Control Locks
Merge Command
5/10/2019 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
The merge command applies changes from one branch into another.
NOTE
The results of this command are not reflected in the Team Foundation version control server until you perform a check-in
operation. For more information, see Check In Pending Changes.
Required Permissions
To use the merge command, you must have the Check out permission set to Allow for the workspace folder
that contains the destination and you must have the Read permission set to Allow for the workspace folder that
contains the source. For more information, see Permissions and groups reference.
Parameters
ARGUMENT DESCRIPTION
source Specifies the file or folder to act as the source of the merge.
OPTION DESCRIPTION
/discard Does not perform the merge operation, but updates the
merge history to track that the merge occurred. This
discards a changeset from being used for a particular
merge.
/version For a selective merge, this option specifies the range that
should be merged into the destination. For a catch-up
merge, this parameter specifies the version before which
all un-merged changes should be merged.
For a selective merge, the version range denotes the
beginning and end points of the set of changes to be
merged. For example, if you attempt to merge version
4~6, the changesets 4, 5, and 6 are merged.
Note
Baseless merges cannot delete files in the target. You can
manually carry over such changes.
Remarks
You can use the merge command of the tf command-line utility to apply changes in an existing source branch to
an existing target branch. You can merge an individual revision or a complete changeset to the target branch. You
can merge changes from the source to the target branch or from the destination to the source branch.
The merge command also lets you query for changes in a source branch which have not been migrated to the
target branch. Additionally, it lets you indicate that certain changes will never be merged from the source to the
destination and should no longer be displayed as candidates for a merge operation.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Baseless Merge
Use baseless merge to merge items that are not directly branched from each other. To perform a baseless merge,
you must use the tf merge command. When you perform a baseless merge, Team Foundation does not have
any information about the relationship of the files in the branches. In a baseless merge, you must perform
manual conflict resolutions. After you have performed the baseless merge and resolved any conflicts, Team
Foundation records the merge history and establishes a relationship between the folders and files.
When you run tf merge, Team Foundation performs an implicit baseless merge between items that have the
same relative name in two previously related version-controlled trees. For example, you might want to merge the
related branches $SRC\ and $TGT. Both branches contain an unrelated file that is named a.txt. When you run tf
merge, Team Foundation establishes a relationship between the two a.txt files if the two files are the same, if
FIPS -compliant encryption is disabled, and if the source file is not related to any other file in the target.
If you run tf merge with the /noimplicitbaseless option set, when Team Foundation tries to merge the two
branches, the two a.txt files will create a namespace conflict when you try to check in the changes. To resolve the
conflict, you must rename one of the files.
Examples
The following example merges changes from MyFile_beta1 that have not been merged into MyFile_RTM.
The following example merges all the changesets up to changeset 137 into branch2.
The following example prints a list of the changesets in branch1 that have not been merged into branch2.
The following example prints a list of changesets in branch2 that have not been merged back into branch1.
The following example discards changeset 137 as a candidate for merging into branch2.
See Also
Tasks
Resolve Conflicts between Two Files
Reference
Command-Line Syntax (Version Control)
Branch Command
Merges Command
Other Resources
Tf Command-Line Utility Commands
Branching and Merging
Merges Command
5/31/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Displays detailed information about past merges between the specified source and destination branches.
Required Permissions
To use the merges command, you must have the Read permission set to Allow for both source and destination
branches. For more information, see Permissions and groups reference.
Parameters
Argument
Description
source
Filters the merge history to include only entries with the specified sources.
This parameter is optional.
destination
Specifies the destination branch for which merge history is displayed.
This parameter is required.
username
Provides a value to the /login option. You can specify a username value as either DOMAIN<em>UserName or
UserName.
TeamProjectCollectionUrl
The URL of the project collection that contains the branches about which you want to display the merge history
(for example, http://myserver:8080/tfs/DefaultCollection).
OPTION DESCRIPTION
/showall Displays all past merges for a given target item under its
current name and all previously used names.
Remarks
For links to other Team Foundation commands that provide additional information about the items in your Team
Foundation version control server and all the workspaces that map to it, see Informational Commands.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example displays information about all merge operations performed between Beta1_branch and
RTM_branch.
Sample output:
The asterisk '*' next to changeset 147 indicates that only some of the changes in that changeset #147 were
merged into changeset #167.
See Also
Reference
Command-Line Syntax (Version Control)
Merge Command
Branch Command
Concepts
Informational Commands
Other Resources
Tf Command-Line Utility Commands
Branching and Merging
Msdn Command
5/10/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Displays a help topic from the MSDN library that contains detailed information about a Team Foundation version
control command.
tf msdn commandname
Parameters
ARGUMENT DESCRIPTION
Remarks
When you need a command and are not sure which one to use, type tf msdn for a list of command reference
topics and links to additional resources. If you use the msdn command without specifying a commandname
parameter, you will see a topic that lists all commands together with usage requirements and a description.
When you specify the commandname parameter, the help topic opens for that specific command. If the system
cannot find a match for the commandname, it searches for aliases and short names. If it does not find a matching
command, alias, or short name, you will get an error message.
For more information about how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example displays a help topic that lists all the version control commands, including a brief
explanation of syntax.
c:\projects>tf msdn
The following example displays a help topic about the workspace command.
See Also
Reference
Help Command (Team Foundation Version Control)
Other Resources
Tf Command-Line Utility Commands
Permission Command
5/31/2019 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Modifies the user access control list (ACL ) and displays authorization settings for an item under version control.
Required Permissions
To use the permission command, you must have the Manipulate security settings permission set to Allow for
the folders being modified, be a member of the Team Foundation Administrators security group, or be a
system administrator on the local computer (Windows Administrator security group). For more information, see
Permissions and groups reference.
Parameters
ARGUMENT DESCRIPTION
TeamProjectCollectionUrl The URL of the project collection that contains the item
for which you want to modify permissions (for example,
http://myserver:8080/tfs/DefaultCollection).
Note
You can specify more than one Itemspec argument.
Username Provides a value to the /login option. You can specify a
username value as either DOMAIN<em>UserName or
UserName.
OPTION DESCRIPTION
## Remarks You can use the permission command (or alternatively its shortcut, perm ) to manage authorization
settings for Team Foundation version control server objects. However, this command does not let you manage
authentication settings such as creating or modifying Team Foundation security groups.
For more information about how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example displays the Team Foundation access control lists (ACLs) for 314.cs.
The following example displays the ACL information that relates to the group "developers" for the collection that
is located at http://myserver:8080/tfs/DefaultCollection/.
The following example enables members of the "leads" group to change their local copies of all items in the
$/baseobjects Team Foundation version control server folder.
The following example removes all permission-related settings from the $/baseobjects folder for members of the
"developers" group.
The following example enables user somealias to make pending changes to his local copy of $/testtproject/314.cs
in his workspace.
The following example denies user somealias the ability to make pending changes to his local copy of
$/testproject/1256.cs.
See Also
Reference
Command-Line Syntax (Version Control)
Other Resources
Tf Command-Line Utility Commands
Proxy Command
5/31/2019 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Configures your client computer to use a proxy server. Adds, deletes, and lists proxy records about the location and
availability of one or more proxy servers within your deployment, including any remote sites.
Required Permissions
To use the proxy command to configure a client computer, you must be a member of the User security group on
the local computer. To use the proxy command to work with proxy records, you must have the
AdminConfiguration permission. For more information, see Permissions and groups reference.
tf proxy /enabled:(true|false)
Parameters
ARGUMENT DESCRIPTION
Url Identifies the proxy server. You must use the following
format: http://proxyServerName:proxyPortNumber.
Where proxyServerName is the name of the proxy server
and proxyPortNumber is the assigned listening port (for
example, http://server:8081).
OPTION DESCRIPTION
/default Specifies the scope of the proxy record. If you add a proxy
record with the default set to global, the first time that a
developer performs a get operation, Team Foundation
Server will redirect that developer's request to the proxy
that is specified by the global record. If you add a proxy
record with the default set to site, the first time that a
developer from within the specified Active Directory
domain performs a get operation, Team Foundation
Server will redirect that developer's request to the proxy
that is specified by the record that is associated with the
site.
You can specify one of the following values:
global
site
all
Remarks
The proxy command has two purposes, and each purpose is aimed at a different type of user.
As a developer, you can use the proxy command to configure your client to use a proxy server or to override the
network defaults for a proxy server. This task is similar to configuring Team Explorer to use a proxy.
As a network administrator, you can use the proxy command to add and manage records about the location of
various proxy servers within your deployment of Team Foundation Server. You can use these records to help
developers configure their workstations to use a proxy. If you define a global proxy, Team Foundation Server can
automatically redirect developers to use it. If you have a complex network topology with multiple Active Directory
domains in various geographic locations, you can set up multiple records and associate each record with a
particular domain. These records can then help you automatically direct developers from each geographical
location to the appropriate proxy for their location.
For more information about how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example automatically detects and configures a client computer to use a proxy, if a proxy record has
been established:
The following example overrides any proxy records on Team Foundation Server and configures a client computer
to use a specified proxy:
The following example adds a global record to Team Foundation Server about the availability of this proxy. The
first time that a developer performs a get operation, Team Foundation Server will redirect all requests from that
developer to the specified proxy.
The following example adds a site record to Team Foundation Server for developers in an Active Directory domain,
which is named corp, to use this proxy server. The first time that a developer from that domain performs a get
operation, Team Foundation Server will redirect all requests from that developer to the specified proxy.
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Lets you resolve conflicts between changed items in your workspace and the latest or destination versions of
items on the server.
Required Permissions
To use the resolve command, you must be either the workspace owner or have the global Administer
workspaces permission set to Allow. You must also have the Read and Check out permissions for the items
involved in a resolve operation set to Allow. For more information, see Permissions and groups reference.
tf resolve [itemspec]
[/auto:(AutoMerge|TakeTheirs|KeepYours|OverwriteLocal|DeleteConflict|KeepYoursRenameTheirs)]
[/preview] [(/overridetype:overridetype | /converttotype:converttype] [/recursive] [/newname:path] [/noprompt]
[/login:username, [password]]
Parameters
ARGUMENT DESCRIPTION
Note
You can specify more than one Itemspec argument.
path Used with the /newname option. Specifies the new path
of the affected file or folder
Note
You cannot specify both an /overridetype and a
/converttotype.
/converttotype Specifies the encoding used for temporary conversion for
the input in a three-way merge operation. The merge
output is saved in the specified encoding in your
workspace. This option is an advanced option and seldom
used. For more information about file encodings, see
Managing File Types.
Note
You cannot specify both an /overridetype and a
/converttotype.
## Remarks You can use the Resolve command to select a resolution for pending changes that conflict with the
server version.
If version conflicts are detected between your version and the version on the destination server during a get,
check-in, or merge operation, a prompt appears for you to select a conflict resolution using the resolve command.
You must resolve conflicts before you can check in your pending changes.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example invokes the Resolve Conflicts dialog box so that you can tell Team Foundation Server
how to deal with pending changes that conflict with the server version.
tf resolve
The following example attempts to resolve all conflicts by automatically merging the changes.
tf resolve /auto:automerge
See Also
Reference
Command-Line Syntax (Version Control)
Merge Command
Get Command
Checkin Command
Difference Command
Concepts
Managing File Types
Other Resources
Tf Command-Line Utility Commands
Resolving Folder Differences and File Conflicts
Comparing Folders and Files
Rollback Command (Team Foundation Version
Control)
5/10/2019 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
You can use this command to roll back the effects of one or more changesets to one or more version-controlled
items. This command does not remove the changesets from an item's version history. Instead, this command
creates in your workspace a set of pending changes that negate the effects of the changesets that you specify.
Required Permissions
To use this command, you must have the Read, Check Out, and Check In permissions set to Allow. For more
information, see Permissions and groups reference.
Parameters
ARGUMENT DESCRIPTION
Note:
You can specify more than one Itemspec argument.
OPTION DESCRIPTION
/version Specifies the current version of the files and folders that
you want to roll back.
Remarks
The tf rollback command negates the effect of each changeset that you specify for each item that you specify. The
following table lists how the operation negates each kind of change.
edit edit
...A ROLLBACK CHANGE AND THE FOLLOWING ADDITIONAL
IF YOU ROLL BACK THIS CHANGE... CHANGE ARE MADE
encoding encoding
rename/move rename/move
delete undelete
merge Change that negates whatever changes were merged into the
current branch.
The following list provides some examples of changes that result from the rollback command:
If you are rolling back a changeset in which an add change occurred, the rollback operation causes a
rollback change and a delete change.
If you are rolling back changeset 521 in which an edit change occurred, the rollback operation causes a
rollback change and an edit change that negates the changes encompassed by the edit change in
changeset 521.
In changeset 132, you merged from $/BranchA/File1.txt to $/BranchB/File1.txt. The changes included
in that merge included edit changes in changesets 92 and 104. In changeset 162, you roll back changeset
132, which results in a rollback change and an edit change to $/BranchB/File1.txt that negates the edit
changes in changesets 92 and 104.
Exit Codes
The exit codes in the following table appear after you run the tf rollback command.
Examples
The following example negates the effect of changeset 23 on all items that were changed in that changeset.
The following example negates the effect of changeset 23 on the file a.txt.
The following example changes the content of a.txt to match the version that was checked in with changeset 23.
The following example changes the content of OurTeamProject to match the last changeset that was applied on
or before midnight on August 31, 2009.
You check in the change as part of changeset 314. The result of this operation is that the edits that you
made in changesets 297, 301, and 305 to $/BranchA/Util.cs are now also applied to $/BranchB/Util.cs.
4. A week later, you realize that the edits that you made to $/BranchA/Util.cs in July are not appropriate for
$/BranchB/Util.cs. You can use the rollback command to negate these changes. When you use the
rollback command to roll back a merge change or a branch change, you have a decision to make.
If you want the changes that you made in July to $/BranchA/Util.cs to be re-applied to
$/BranchB/Util.cs in future merges, you should type the following command:
If you want the changes that you made in July to $/BranchA/Util.cs to never be re-applied to
$/BranchB/Util.cs in future merges, you should type the following command:
If you omitted the /keepmergehistory option, the merge change will apply to $/BranchB/Util.cs
all changesets that were applied to $/BranchA/Util.cs since changeset 292, including changesets
297, 301, 305. In other words, a future merge will undo the rollback change.
If you included the /keepmergehistory option, the merge operation will apply to
$/BranchB/Util.cs all changesets that were applied to $/BranchA/Util.cs since changeset 292,
excluding changesets 297, 301, and 305. In other words, a future merge will not undo the rollback
change. Therefore, the content on BranchA might not match the content on BranchB.
See Also
Reference
Merge Command
Concepts
Operations Available Only From the Command-Line (Team Foundation Version Control)
Other Resources
Tf Command-Line Utility Commands
Shelvesets Command
5/31/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Displays information about a set of shelved changes.
Required Permissions
To use the shelvesets command, you must the have Read permission and the Check out permission set to
Allow for the items in the shelvesets. For more information, see Permissions and groups reference.
Parameters
ARGUMENT DESCRIPTION
OPTION DESCRIPTION
/owner Specifies one or more shelveset owners. You can use wildcard
characters.
Brief displays the shelveset name, the name of the user who
created it, and a shelveset comment, if one exists. Detailed
displays the shelveset name, owner, and comment in addition
to a list of associated work items and any check-in notes.
Brief is the default value.
Remarks
Shelvesets are created by the shelve command. Shelvesets are stored on the Team Foundation Server and can be
retrieved into a workspace by any user who has sufficient permissions using the Unshelve Command. Unlike a
changeset, a shelveset is a non-versioned entity. If you or another user unshelve the items of which a shelveset
consists, edit several files, and re-shelve the shelveset, Team Foundation does not create a new version of the
items for future comparison and maintains no record of who revised the items, when, or in what manner. For
more information about deciding whether to shelve or check in a set of pending changes and a general overview
of shelving, see Working with Shelvesets.
For detailed information about the individual source file revisions of which a particular shelveset consists, you can
use the Status Command with the /shelveset option.
You can compare a shelved revision to its base shelveset version without unshelving the item into your workspace.
You can use this feature to conduct a quick peer code review.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example displays information about the BuddyTest_23 shelveset for the Team Foundation Server to
which the current directory maps.
The following example displays information about the shelvesets on the Team Foundation Server to which the
current directory maps.
See Also
Reference
Command-Line Syntax (Version Control)
Status Command
Changeset Command
Shelve Command
Unshelve Command
Concepts
Working with Shelvesets
Other Resources
Tf Command-Line Utility Commands
Undelete Command
5/31/2019 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
The undelete command restores items that were previously deleted.
Note:
** **The results of this command are not visible in other workspaces until you perform a check-in operation.
For more information, see Check In Pending Changes.
Required Permissions
To use the undelete command, you must have the Check out permission set to Allow. If you include the /lock
option with a value other than none, you must have the Lock permission set to Allow. Additionally, you must
own the workspace or have the global Administer workspaces permission set to Allow. For more information,
see Permissions and groups reference.
Parameters
ARGUMENT DESCRIPTION
OPTION DESCRIPTION
Remarks
The Undelete command of the tf command-line feature schedules specified files or folders for restoration
pending the completion of a check-in operation. It also retrieves the specified items from the server to the local
disk unless you explicitly include the /noget option.
When files or folders that have the same name have been deleted from the same server folder, you must include
a value for the deletionID parameter to indicate which of the deleted items that you want to restore. You can
obtain a deletionID using the dir command.
If you want to change the file after restoring it, you may check out the file for editing with the checkout command
as usual.
When your itemspec specifies a folder, Team Foundation restores all its files and subfolders and the files they
contain, by default. If you do not want to restore all the items in a folder, you must first undelete the folder and its
items and then delete the items that you do not want to keep.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example restores 314.cs to the server folder from which 314.cs was deleted and retrieves a read-
only copy of the latest version in the current workspace.
C:\projects>tf undelete c:\math\314.cs
The following example displays deletion IDs for all items on the server that have been deleted more than one
time.
Sample output:
$/projects/math/314.cs;X10
$/projects/math/314.cs;X11
The following example restores the X11 version of 314.cs to the server folder from which the file was deleted and
retrieves a read-only copy of the latest version in the current workspace.
See Also
Reference
Command-Line Syntax (Version Control)
Rename Command (Team Foundation Version Control)
Delete Command
Dir Command
Concepts
Pending Changes
Understanding Lock Types
Other Resources
Tf Command-Line Utility Commands
Unlabel Command
5/31/2019 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Removes an item from an existing label in the server for Team Foundation version control.
Required Permissions
To use the unlabel command, you must either own the label, or have the Administer labels permission set to
Allow. For more information, see Permissions and groups reference.
Parameters
ARGUMENT DESCRIPTION
TeamProjectCollectionUrl The URL of the project collection that contains the item
that you want to remove from an existing label (for
example, http://myserver:8080/tfs/DefaultCollection).
Note
You can specify more than one itemspec argument.
OPTION DESCRIPTION
/recursive Unlabels all items in the particular directory and all the
subdirectories that match the itemspec.
Examples
The following example removes the "goodbuild" label from 314.cs.
The following example removes the "Beta1" label from all files and folders in the collection at
http://myserver:8080/tfs/DefaultCollection.
See Also
Reference
Command-Line Syntax (Version Control)
Label Command (Team Foundation Version Control)
Labels Command
Concepts
Use Labels to Take a Snapshot of Your Files
Other Resources
Tf Command-Line Utility Commands
View Command
5/31/2019 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
The view command retrieves a specific version of a file to a temporary folder on your computer and displays it.
Required Permissions
To use the view command, you must have the Read permission set to Allow. For more information, see
Permissions and groups reference.
Parameters
Argument
Description
TeamProjectCollectionUrl
The URL of the project collection that contains a specific version of a file about which you want to retrieve
information (for example, http://myserver:8080/tfs/DefaultCollection).
shelvesetname [:owner ]
Identifies the shelveset. The optional owner argument is used to specify a shelveset that is not owned by the
current user.
Itemspec
Identifies the file or folder to retrieve. For more information about how Team Foundation parses itemspecs to
determine which items are within scope, see Command-Line Options.
Note
You can specify more than one Itemspec argument.
Versionspec
Provides a value such as C3 for the /version option. For more information about how Team Foundation parses a
version specification to determine which items are within its scope, see Command-Line Syntax (Version Control).
username
Provides a value to the /login option. You can specify a username value as either DOMAIN<em>UserName or
UserName.
localfile
Provides the path of the folder to which you want to output the file.
OPTION DESCRIPTION
/version Specifies the version of the file to open for viewing. If you
omit this option, view retrieves the latest Team
Foundation version control server version.
## Remarks The view command of the tf command-line utility retrieves a read-only copy of a file from the Team
Foundation version control server to a temporary folder on your computer and displays its contents. Unless you
specify a particular version, Team Foundation retrieves the latest version of the file from the Team Foundation version
control server.
The view command does not retrieve files into your workspace or check them out. See Get Command and
Checkout and Edit Commands for more information about how to get the Team Foundation version control server
version of and check out files.
You can use the Difference Command to view the differences between two versions of a file.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Output Options
By default, Team Foundation displays the contents of the file in the viewer associated with its file type.
If you include the /console option, Team Foundation prints the contents of the file to the command console.
Likewise, if Team Foundation cannot locate a viewer for the type of file you have specified, it prints the contents of
the file to the command console.
Finally, you can redirect the contents of a file to standard out using | or > in order to save it in another file or pass
it to another program for post-processing.
Examples
The following example displays the latest version of the file 314.c.
The following example displays the version of 314.c that was checked in with changeset 1999.
The following example retrieves version 5 of 314.c and writes it to the file 314.old.
The following example displays the latest version of each file that matches the wildcard "*.cs".
See Also
Reference
Command-Line Syntax (Version Control)
Checkout and Edit Commands
Get Command
Difference Command
Other Resources
Tf Command-Line Utility Commands
Workfold Command
5/31/2019 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Creates, modifies, or displays information about the mappings between your workspace folders and the folders
on the server for Team Foundation version control.
Required Permissions
To use the workfold command, you must be the owner of the specified or implied workspace or have the global
Administer workspaces permission set to Allow. For more information, see Permissions and groups reference.
tf workfold /cloak
serverfolder [/workspace:workspacename] [/collection:TeamProjectCollectionUrl] [/login:username,[password]]
Parameters
Argument
Description
workspacename
Specifies the name of the workspace on which the command operates for the /workspace option.
serverfolder
Specifies the name of a Team Foundation version control server folder.
localfolder
Specifies the name of a local folder.
TeamProjectCollectionUrl
The URL of the project collection that contains the folders that you want to compare with server folders (for
example, http://myserver:8080/tfs/DefaultCollection/).
username
Provides a value to the /login option. You can specify a username value as either DOMAIN\UserName or
UserName.
OPTION DESCRIPTION
Remarks
You can use the workfold command of the tf command-line utility to create and edit workspace mappings. A
workspace mapping creates a client-side folder into which all files and subfolders in the Team Foundation version
control server folder are retrieved when you execute a tf get operation. This get will not work if the client-side
folder is cloaked.
You can also specify an asterisk (*) wildcard to map a Team Foundation Server folder and its immediate items to
your local workspace. This is often referred to as single folder mapping.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Options for Workspace Mapping
A workspace mapping is a list of active and cloaked items. You can add Team Foundation version control server
items to the mapped list in the workspace using the /map option. You can also exclude an item from the
workspace explicitly by using the /cloak option. You can only cloak the items that have a mapped parent.
Cloaking is an effective way to improve the speed of batch Get operations and to conserve space on disk.
Use cloaking with discretion. To avoid compilation and integration problems, you should only cloak those items
that you know to be outside the scope of your current and future projects, such as images and external
documentation files.
You can use the /unmap and /decloak options to selectively delete mapped and cloaked entries from the
workspace mapping.
How Workspace Mappings are Applied
By default, workspace mappings are applied recursively. When you map a local folder to a Team Foundation
version control server folder, the system implicitly creates a mapping between all its current and future
subfolders. For example, if you map $/projects to c:\projects, subsequently add a project called
$/projects/project_one, and then run a get of the workspace, Team Foundation automatically creates a local
working folder named project_one in the C:\projects directory.
In this example, you can use a wildcard, "*", to map a server folder and its immediate items to your local
workspace:
In this example, you can override the automatically-created mapping between $/projects/project_one and
C:\projects\project_one by using the workfold command as follows:
Examples
The following example displays the mappings for the workspace in which c:\projects resides.
c:\projects>tf workfold
The following example displays the mapping for the local file word.cs.
The following example maps the folder C:\DifferentWorkfold to the Team Foundation version control server
folder $/projects/project_one and replaces the previous workspace mapping for the $/projects/project_one Team
Foundation version control server folder.
See Also
Tasks
Cloak and Uncloak Folders in a Workspace
Reference
Command-Line Syntax (Version Control)
Workspace Command
Concepts
Create a Workspace to Work with your Project
Other Resources
Tf Command-Line Utility Commands
Create a Workspace and Get Files for the First Time
Workspace Command
8/30/2019 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Lets you create, delete, view, or modify properties and mappings associated with a workspace.
Required Permissions
To modify or delete an existing workspace, you must be the owner or have the global Administer workspaces
permission set to Allow. To create a workspace, you must have the global Create a workspace permission set
to Allow. To create workspaces for other users, you must have the Administer workspaces permission set to
Allow. For more information, see Permissions and groups reference.
Parameters
ARGUMENT DESCRIPTION
TeamProjectCollectionUrl The URL of the project collection that contains the workspace
about which you want to create, edit, delete, or display
information (for example,
http://myserver:8080/tfs/DefaultCollection).
ARGUMENT DESCRIPTION
OPTION DESCRIPTION
/newowner Specifies the user name for the new owner of the workspace.
Remarks
A workspace is a local copy of the files and folders on the server, plus any changes that you have made locally.
When you add, edit, delete, move, rename, or otherwise change any version-controlled item, your changes are
isolated in your workspace where you can make and test your changes. Your pending changes are committed to
the server and become available to other users outside your workspace when you perform a check-in.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Creating a Workspace
Before you can add files to the version control server or check out items on the server in order to edit them, you
must create a workspace or associate an existing one with the current directory. For more information, see
Create a Workspace and Get Files for the First Time.
To make the current directory a working folder for an existing workspace on your computer, type tf workspace
workspacename, where workspacename is the name of the existing workspace. The Edit Workspace dialog box
appears. Click click here to enter a new working folder, type the server path for which you want to map the
current directory in the Source Control Folder box, type the current directory in the **Local Folder box,
and click **OK.
When you create a new workspace, you can specify a template workspace as part of the /new option. When you
specify a template workspace, Team Foundation creates a new workspace on the current computer, sets the
owner to the current owner, and replicates the following workspace properties into the new workspace from the
template workspace: mappings and comment. If no name is specified, the system uses a name based on the
current computer name. When you create a workspace using a template, Team Foundation does not retrieve the
files to which it maps from the server. Use the Get Command to synchronize the new workspace with the latest
version on the server.
Single Folder Mapping
You can choose to map only the immediate children of a version control folder to a local workspace. To do this,
add an asterisk wild-card character in the Source Control Folder box in the Add Workspace dialog box. For
example, $/folder/*. Otherwise, by default, all the children of the version control folder are recursively mapped to
the local workspace.
Single folder mapping within a version control hierarchy is useful because it limits the number of items
downloaded to the client computer. Another way to limit downloaded files is to cloak files that you do not need to
have in your workspace. For more information, see Cloak and Uncloak Folders in a Workspace. This provides
faster download times and saves disk space on the client computer.
Deleting a Workspace
If you delete a workspace that contains pending changes, Team Foundation cancels the pending changes as part
of the delete process. Deleting a workspace does not delete the files and folders on the client computer that were
in that workspace.
NOTE
Commands run manually require the /noprompt option to bypass user acknowledgement. Be careful if using PowerShell's
Start() method to run commands, as this option can be automatically set.
Editing a Workspace
You can change the following workspace attributes:
Workspace Name
Comment
Working folder mappings
If no workspace specification is provided, the workspace for the current folder is used.
Examples
The following example opens the Add Workspace dialog box and creates a new workspace. You can use the
Add Workspace dialog box to edit the source control folder, owner, computer, comment, and local folders.
The following example creates a new workspace called Beta1 and assigns jenh as the workspace owner. You must
have the AdminWorkspaces permission to assign ownership of a new workspace to another user. For more
information on security permissions, see Permissions and groups reference.
The following example creates a new workspace by using the Beta1 workspace that is owned by jenh as a
template.
The following example removes the Beta1 workspace from the server.
c:\projects>tf workspace
The following example opens the Beta1 workspace for which user jenh is the owner so that you can see its
properties and mappings. If you have the AdminWorkspaces permissions, you can change the workspace
properties and mappings.
See Also
Tasks
Cloak and Uncloak Folders in a Workspace
Reference
Command-Line Syntax (Version Control)
Workspaces Command
Concepts
Create a Workspace to Work with your Project
Other Resources
Tf Command-Line Utility Commands
Create a Workspace and Get Files for the First Time
Workspaces Command
5/31/2019 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Displays information about workspaces in the system and updates cached information about a user name or
computer name change on the server that is running Visual Studio Team Foundation Server.
Required Permissions
To use the workspaces command, you must have the Read permission set to Allow. For more information, see
Permissions and groups reference.
tf workspaces /remove:(*|workspace1[,workspace2,...])
/collection:(*|TeamProjectCollectionUrl)
Parameters
ARGUMENT DESCRIPTION
OPTION DESCRIPTION
Remarks
The workspaces command of the tf command-line utility displays information about workspaces on the current
computer, owned by a specified user, or for all workspaces associated with a specific Team Foundation Server. For
each workspace, Team Foundation displays the name, owner, comment, and computer name. With detailed
output, it also shows the workspace mappings. Unless you provide a filter such as owner, computer or workspace
name, Team Foundation only displays information about the workspaces that you have created.
For more information about how to edit workspace properties, see Workspace Command.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
The following example displays a list of all workspaces for the current user on the current computer.
c:\projects>tf workspaces
The following example displays the list of all workspaces for all users on all computers that have been created in
the following project collection at the address http://myserver:8080/tfs/DefaultCollection.
The following example displays detailed information about all workspaces that the current user has created in the
project collection at the address http://myserver:8080/tfs/DefaultCollection.
The following example displays detailed information including a list of workspace mappings about the workspace
"WS1," which is owned by the current user and is located on the current computer.
The following example removes all cached workspaces from the cache in the project collection at the address
http://myserver:8080/tfs/DefaultCollection.
See Also
Reference
Command-Line Syntax (Version Control)
Workspace Command
Workfold Command
Concepts
Create a Workspace to Work with your Project
Other Resources
Tf Command-Line Utility Commands
Create a Workspace and Get Files for the First Time
Azure Repos with Slack
8/19/2019 • 5 minutes to read • Edit Online
If you use Slack, you can use the Azure Repos app for Slack to easily monitor your Azure repositories. You can set
up and manage subscriptions to receive notifications in your channel whenever code is pushed/checked in and
whenever a pull request (PR ) is created, updated or a merge is attempted. This app supports both Git and Team
Foundation Version Control (TFVC ) events.
Prerequisites
To create subscriptions in a Slack channel for repository-related events, you must be a member of the Azure
Project Administrators group. To get added, see Set permissions at the project or collection level.
To receive notifications, the Third-party application access via OAuth setting must be enabled for the
organization. See Change application access policies for your organization.
NOTE
Notifications are currently not supported inside direct messages.
You can only link the Azure Repos app for Slack to a project hosted on Azure DevOps Services at this time.
3. Use the /azrepos Slack handle to interact with the app. A full list of commands is provided in the Command
reference section of this article.
2. To start monitoring a repository, use the following slash command inside a channel:
The repository URL can be to any page within your repository that has your repository name.
For example, for Git repositories, use:
/azrepos subscribe https://dev.azure.com/myorg/myproject/_git/myrepository
3. The subscribe command gets you started with a default subscription. For Git repositories, the channel is
subscribed to the Pull request created event, and for TFVC repositories, the channel is subscribed to the
Code checked in event.
Manage subscriptions
To view, add and remove subscriptions for a channel, use the subscriptions command:
/azrepos subscriptions
This command lists all the current subscriptions for the channel and allows you to add new subscriptions or
remove existing ones. When adding subscriptions, you can customize the notifications you get by using various
filters, as described in the following section.
Using filters effectively to customize subscriptions
When a user subscribes to a repository using /azrepos subscribe command, a default subscription is created.
Often, users have the need to customize these subscriptions. For example, users may want to get notified only
when PRs have a specific reviewer.
The following steps demonstrate how to customize subscriptions.
1. Run the /azrepos subscriptions command.
2. In the list of subscriptions, if there is a subscription that is unwanted or must be modified (Example: creating
noise in the channel), select the Remove button.
3. Select the Add subscription button.
4. Select the required repository and the desired event.
5. Select the appropriate filters to customize your subscription.
Example: Get notifications only when my team is in the reviewer list for a PR
Example: Tell me when merge attempts fail due to a policy violation
NOTE
All the filters are typically drop-downs. However if the drop-down were to have greater than 100 items, then users are
asked to enter the values manually.
For the TFVC Code Checked in event, the filter Under path must be of the format $/myproject/path .
Troubleshooting
If you are experiencing the following errors when using the Azure Repos App for Slack, follow the procedures in
this section.
Sorry, something went wrong. Please try again.
Configuration failed. Please make sure that the organization '{organization name}' exists and that you have
sufficient permissions.
Sorry, something went wrong. Please try again.
The Azure Repos app uses the OAuth authentication protocol, and requires Third-party application access via
OAuth for the organization to be enabled. To enable this setting, navigate to Organization Settings > Security >
Policies, and set the Third-party application access via OAuth for the organization setting to On.
Configuration failed. Please make sure that the organization '{organization name }' exists and that you have
sufficient permissions.
Sign out of Azure DevOps by navigating to https://aka.ms/VsSignout using your browser.
Open an In private or incognito browser window and navigate to https://aex.dev.azure.com/me and sign in. In
the dropdown under the profile icon to the left, select the directory that contains the organization containing the
repository to which you wish to subscribe.
In the same browser, start a new tab, navigate to https://slack.com , and sign in to your work space (use web
client). Run the /azrepos signout command followed by the /azrepos signin command.
Select the Sign in button and you'll be redirected to a consent page like the one in the following example. Ensure
that the directory shown beside the email is same as what was chosen in the previous step. Accept and complete
the sign in process.
If these steps don't resolve your authentication issue, contact us at AzureDevOpsSlackApps@microsoft.com .
Related articles
Azure Boards with Slack
Azure Pipelines with Slack
Create a service hook for Azure DevOps with Slack
Launch Visual Studio via Azure DevOps
3/5/2019 • 2 minutes to read • Edit Online
To set up Visual Studio without Azure DevOps, learn how to get started. To host your own server, learn how to
install and set up Azure DevOps Server.
Azure DevOps is free for up to five users with access to Basic features and for unlimited Visual Studio subscribers
and Stakeholders who can access limited features. Learn what else you get with Azure DevOps. If you want, you
can also use Azure DevOps with any IDE or code editor, like the following:
Eclipse, Android Studio, or IntelliJ
Xcode (see Git or TFVC )
Visual Studio Code
How do I set up Visual Studio 2015 for Azure DevOps during sign in?
1. Download and install Visual Studio, if you don't have the version you want already. Which versions can I use
with Azure DevOps?
If you have a Visual Studio subscription that includes the Visual Studio IDE, get the version that's available
with your subscription.
2. Start Visual Studio, and then sign in to create your profile.
This profile saves your settings and roams with you when you sign in to Visual Studio on any computer.
Why else should I sign in? If you're a Visual Studio subscriber, use the sign-in address for your subscription.
Can't sign in?
3. Enter your sign-in address, and then enter your password.
4. Add your Visual Studio profile details. You have to do this only once.
These changes are saved with your profile, and your settings roam with you wherever you sign in.
8. To view your new organization, sign in to https://dev.azure.com/{yourorganization} .
Having browser problems?
Next steps
Add users to your organization
Related articles
Add code to Git or Team Foundation Version Control.
Create your backlog to organize your work, manage your process, or customize your process.
Learn how to migrate from Subversion (SVN) to Git,
including history
6/4/2019 • 7 minutes to read • Edit Online
When moving to Git from another version control system like Subversion (SVN ), we generally recommend that
you perform a "tip migration", which migrates just the latest version of the repository contents, without including
history. However, many people want to perform a more advanced migration, including history. This guidance will
introduce a history with migration.
SVN migrations to Git can vary in complexity, depending on how old the repository is and how many branches
were created and merged, and whether you're using regular SVN or close relative like SVK.
It could be simple if:
You have a new repository
You have a standard setup of a trunk, branches, and tags directory
It's likely going to be complex if:
Your team has performed many branching and merging operations
Your repository follows a non-standard directory setup
Your directory setup has changed over time
There are several ways to migrate from SVN to Git. The approach outlined in this article is based on using git-svn,
a Git extension, which can be used to check out a Subversion repository to a local Git repository and then push
changes from the local Git repository back to the Subversion repository. These steps give a detailed overview of
the process for migrating from SVN to Git in a Windows environment, without synchronizing back to the original
SVN repository. The result will be a bare Git repository for sharing with the rest of your team.
NOTE
Before you try to migrate your source code from a centralized version control system to Git, be sure that you familiarize
yourself with the differences between centralized and distributed version control systems, and plan your team's migration.
After you've prepared, you can begin the migration.
TIP
Bare Git repositories are structured differently and given the fact that it doesn't have a working directory prevent direct
commit to the repository.
Git users
To extract a list of all SVN users from the root of your local Subversion checkout, run this PowerShell command:
svn.exe log --quiet | ? { $_ -notlike '-*' } | % { "{0} = {0} <{0}>" -f ($_ -split ' \| ')[1] } | Select-Object
-Unique
This command will retrieve all the log messages, extract the usernames, eliminate any duplicate usernames, sort
the usernames, and place them into a "authors-transform.txt" file. You can then edit each line in the file to create a
mapping of SVN users to a well-formatted Git user. For example, you can map jamal = jamal <jamal> to
jamal = Jamal Hartnett <jamal@fabrikam-fiber.com> .
git svn clone ["SVN repo URL"] --prefix=svn/ --no-metadata --authors-file "authors-transform.txt" --stdlayout
c:\mytempdir
NOTE
The --prefix=svn/ is necessary because otherwise the tools can't tell SVN revisions from imported ones. We recommend
setting a prefix (with a trailing slash), as your SVN-tracking refs will then be located at refs/remotes/$prefix/ , which is
compatible with Git's own remote-tracking branch layout ( refs/remotes/$remote/ ).
Setting a prefix is also useful if you wish to track multiple projects that share a common repository. By default, the prefix is set
to origin/ .
If you are using the standard trunk, branches, tags layout you'll just put --stdlayout . However, if you have
something different you may have to pass the --trunk , --branches , and --tags to find what is what. For
example, if your repository structure was trunk/companydir and you branched that instead of trunk, you would
probably want --trunk=trunk/companydir --branches=branches .
git svn clone ["SVN repo URL"] --prefix=svn/ --no-metadata --trunk=/trunk --branches=/branches --tags=/tags --
authors-file "authors-transform.txt" c:\mytempdir
NOTE
This command can take a few minutes to several hours depending on the size of the SVN repository. Upon completion, you
will have a Git checkout of your repository.
Convert version control-specific configurations
If your SVN repo was using svn:ignore properties, you can convert to a .gitignore file using:
cd c:\mytempdir
git svn show-ignore > .gitignore
git add .gitignore
git commit -m 'Convert svn:ignore properties to .gitignore.'
TIP
Read more about .gitignore: Ignore file changes with Git
2. Push the local Git repository to the new bare Git repository
cd c:\mytempdir
git remote add bare c:\new-bare.git
git config remote.bare.push 'refs/remotes/*:refs/heads/*'
git push bare
3. Rename "trunk" branch to "master" Your main development branch will be named "trunk", which matches
the name it was in Subversion. You'll want to rename it to Git's standard "master" branch using:
cd c:\new-bare.git
git branch -m trunk master
4. Clean up branches and tags git-svn makes all of Subversions tags into very-short branches in Git of the
form "tags/name". You'll want to convert all those branches into actual Git tags or delete them.
Migrate SVN tags to be Git tags
cd c:\new-bare.git
git for-each-ref --format='%(refname)' refs/heads/tags | % { $_.Replace('refs/heads/tags/','') } | % { git tag
$_ "refs/heads/tags/$_"; git branch -D "tags/$_" }
Advanced migrations
Create all the SVN branches as proper Git branches
While it's easy to create all SVN branches as a proper Git branches, it's recommended that you evaluate the
following points before you continue:
If there are Feature branches: Can you wait until they integrate to the trunk before migrating?
If there are Release branches: Does it make sense to keep SVN around for servicing? If you migrate feature
branches, are you prepared to service branches out of Git?
If you still want to migrate existing branches, run the following PowerShell command:
NOTE
This command can take a few minutes to several hours depending on the size of the SVN repository. Upon completion, you
will have a Git checkout of your repository.
Reference information
Choosing the right version control for your project
Learn Git
Ignore file changes with Git
Migrate from TFVC to Git
Authors: Hosam Kamel, William H. Salazar | Find the origin of this article and connect with the ALM | DevOps
Rangers here
(c) 2017 Microsoft Corporation. All rights reserved. This document is provided "as-is." Information and views
expressed in this document, including URL and other Internet Web site references, may change without notice. You
bear the risk of using it.
This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You
may copy and use this document for your internal, reference purposes.