Azure Repos Documentation
Azure Repos Documentation
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
Connect your favorite development environment
Connect your favorite development environment to Azure Repos to access your repos and manage your work.
Share your code using:
Command-line
Visual Studio Code
Visual Studio
Xcode
Eclipse
IntelliJ
Review code with pull requests
Review code with your team and make sure that changes build and pass tests before it's merged.
Create a pull request
Link work items to pull requests
Set up branch policies
Squash merge pull requests
Git branch and pull request workflows
Leave comments
Vote on the changes
Protect branches with policies
There are a few critical branches in your repo that the team relies on to always be in good shape, such as your
master branch. Require pull requests to make any changes on these branches. Developers who push changes
directly to the protected branches will have their pushes rejected.
Add conditions to your pull requests to enforce a higher level of code quality in your key branches. A clean build
of the merged code and approval from multiple reviewers are extra requirements that you can set to help
protect your key branches.
Branch policies overview
How to configure branch policies
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.
Pull request status overview
Create a PR status server with Node.js
Use Azure Functions to create custom branch policies
Configure a branch policy for an external service
Isolate code with forks
Forks are a great way to isolate experimental, risky, or confidential changes from the original codebase. 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. After 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 about forks
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
Learn more
Learn more about Git
Learn more about TFVC
Choosing the right version control for your project
3/18/2021 • 9 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
Visual Studio and on the web portal. on the web portal. You can annotate
You can annotate files to see who files to see who changed a line, and
changed a line, and when they when they changed it.
changed it.
Tag your files You can apply labels to a version of You can apply tags from the command
one or more files from either Visual prompt to individual commits. View
Studio or the command prompt. Each tags in the Visual Studio history
file can have label applied to a different window.
version.
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 commit. (Anyone can claim any
can identify which user checked in a identity as the author or committer.)
changeset and use compare to see You can identify when changes were
what they changed. Looking at a file, made what was changed using history,
you can annotate it to identify who compare, 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
build any combination of content you to build one project at a time, and one
want within the project collection. or 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
lightweight discussions, you can also about 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
permissions at the file level. You more branches. The most granular
can lock files. permissions you can apply are to a
repository or a branch. Files
You can browse your files on the cannot 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 You can create a branch from (from
or 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 por tal: Can browse, tasks are not yet available.
comment, annotate, and see TFS web por tal: Can browse,
history of the codebase. comment, annotate, and see
TF Command prompt: history of the codebase.
Installed with Visual Studio. Third-par ty 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
and shelvesets, and perform other perform other tasks such as ad hoc
tasks such as ad hoc downloading of downloading of selected parts of your
selected parts of your codebase as a codebase as a .zip file.
.zip file.
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
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 main 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 main.
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 main . Branch policies enable you to:
Isolate work in progress from the completed work in your main branch.
Guarantee that changes build before they get to main.
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 main .
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. You can use the Azure DevOps CLI to discover a
list of projects. 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 main 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.
Azure DevOps Ser vices | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 - TFS
2017
Functional code search command filters extend your ability to refine your search across repositories beyond
what is documented in Get started with semantic search. To perform code searches, the Code Search
Marketplace extension must be installed for your organization or collection.
Prerequisites
You must install Code Search
For more information, see Install and configure search.
To use Code Search, you must have at least a Basic access.
Users granted Stakeholder access don't have access to code, and so don't have access to Code Search.
Users granted Stakeholder access for a private project can perform code searches, as they have Full Access to
the code.
When you're searching across the organization or collection, only results for which a project member has
access are listed.
NOTE
You can't search code in forked repositories.
USA GE EXA M P L E
Find all occurrences of the word QueueJobsNow in the path QueueJobsNow path:VisualStudio/Services/Framework
VisualStudio/Services/Framework and its subpaths.
Enclose the argument to the filter in double-quotes if it QueueJobsNow path:"VisualStudio/Windows Phones and
contains a space. Devices/Services"
Find all occurrences of the word QueueJobsNow in all files QueueJobsNow file:queueRegister*
where the filename starts with queueRegister.
USA GE EXA M P L E
Find all instances of "ToDo" comments in your code Select comment: and enter todo
Search in specific locations, such as within a particular path Use a search string such as
Driver path:MyShuttle/Server
USA GE EXA M P L E
Search for files by name or just by file extension Driver file:GreenCabs.cs . The search string
error ext:resx could be useful if you want to review all
error strings in your code. Even if your plain text search
string matches part of a filename, the file appears in the list
of found files. This search works without matching specific
file type functions.
TIP
Code Search remembers your last settings, such as the project and repository or path that you searched in. Clear the
checkboxes to search across all projects easily with the Clear all links when you want to search in a different scope. In the
results pane, Code Search highlights up to the first 100 hits or matches found in the target files.
Next steps
Search work items
Related articles
Get started with Search
Search artifacts and packages
Search work items
Search wiki
Search FAQs
Start using Azure Repos
3/20/2021 • 2 minutes to read • Edit Online
Use this guide to sign up and start using Azure Repos. If you're new to Azure Repos, see What is Azure Repos?
Azure Repos 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
Get started with permissions, access, and security groups
About projects and scaling your organization
Choosing the right version control for your project
3/18/2021 • 9 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
Visual Studio and on the web portal. on the web portal. You can annotate
You can annotate files to see who files to see who changed a line, and
changed a line, and when they when they changed it.
changed it.
Tag your files You can apply labels to a version of You can apply tags from the command
one or more files from either Visual prompt to individual commits. View
Studio or the command prompt. Each tags in the Visual Studio history
file can have label applied to a different window.
version.
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 commit. (Anyone can claim any
can identify which user checked in a identity as the author or committer.)
changeset and use compare to see You can identify when changes were
what they changed. Looking at a file, made what was changed using history,
you can annotate it to identify who compare, 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
build any combination of content you to build one project at a time, and one
want within the project collection. or 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
lightweight discussions, you can also about 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
permissions at the file level. You more branches. The most granular
can lock files. permissions you can apply are to a
repository or a branch. Files
You can browse your files on the cannot 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 You can create a branch from (from
or 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 por tal: Can browse, tasks are not yet available.
comment, annotate, and see TFS web por tal: Can browse,
history of the codebase. comment, annotate, and see
TF Command prompt: history of the codebase.
Installed with Visual Studio. Third-par ty 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
and shelvesets, and perform other perform other tasks such as ad hoc
tasks such as ad hoc downloading of downloading of selected parts of your
selected parts of your codebase as a codebase as a .zip file.
.zip file.
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, Star t 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.
Create a project
If you signed up for Azure DevOps with an existing MSA or GitHub identity, you're automatically prompted to
create a project. You can create either a public or private project. To learn more about public projects, see What is
a public project?.
1. Enter a name for your project, select the visibility, and optionally provide a description. Then choose
Create project .
The name can't contain special characters (such as / : \ ~ & % ; @ ' " ? < > | # $ * } { , + = [ ] ),
can't begin with an underscore, can't begin or end with a period, and must be 64 characters or less.
Any one can view public projects. With private projects, only people who you give access to the project
can view it.
Azure DevOps Ser vices | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 - TFS
2013
In this quickstart, learn how to share your code with others. After you create a new organization and project in
Azure DevOps, you can begin coding with Git.
To work with a Git repo, you clone it to your computer. Cloning a repo creates a complete local copy of the repo
for you to work with. Cloning also downloads all commits and branches in the repo, and sets up a named
relationship with the repo on the server. Use this relationship to interact with the existing repo, pushing and
pulling changes to share code with your team.
2. Select Clone in the upper-right corner of the Code window and copy the URL.
3. Open the Git command window (Git Bash on Git for Windows). Go 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 Clone
URL in the previous step. See the following example:
git clone https://FabrikamFiber01@dev.azure.com/FabrikamFiber01/FabrikamFiber01-
01/_git/FabrikamFiber01-01
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-web
Keep this command window open, as you'll use it in the following steps.
1. From your web browser, open the project for your organization, and select Code . If you don't have a
project, create one now.
2. Select Clone in the upper-right corner of the Code window, and copy the URL.
3. Open the Git command window (Git Bash on Git for Windows). Go 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 Clone
URL in the previous step. See the following example:
Git downloads a copy of the code in a new folder for you to work with. The download includes all
commits and branches from the repo.
4. Switch your directory to the repository that you cloned.
cd contoso-demo
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. It
also creates 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.
When you clone the repository, the default branch (typically main ) is checked out. Because you cloned, your
local copy of main has the latest changes.
If you're working with a previously cloned repository, ensure that you've checked out the right branch (
git checkout main ) and that it's up to date ( git pull origin main ) 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 main 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 main 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.
3. Commit your changes by entering the following commands in the Git command window:
git add .
git commit -m "My first commit"
The git add . command stages any new or changed files, and git commit -m creates a commit with the
specified commit message.
4. Push your changes to the Git repo on the server. Enter the following command into 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 main 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
main . 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.
Select Create to create the pull request.
4. You can view the details of your pull request from the Over view tab. You can also view the changed files,
updates, and commits in your pull request from the other tabs. Select Complete to begin the process of
completing the pull request.
5. Select Complete merge to complete the pull request and merge your code into the main branch.
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 Create, view, and manage pull requests.
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, for example Git Bash on Git for Windows, and browse to the folder
where you want the code from the repo that is 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 into a new folder for you to work with. The download includes all
commits and branches from the repo.
4. Switch your directory to the repository that you 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 main 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 main command switches you to the main branch. The git pull origin main command pulls
down the latest version of the code in the main 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.
View history
1. Switch back to the web portal, and select Histor y from the Code page to view your new commit.
2. Switch to the Files tab, and select the README file to view your changes.
1. Switch back to the web portal, and select Histor y from the Code tab to view your new commit. Two
commits appear: the first commit, where the README and .gitignore were added upon repo creation, and
the commit you just made.
2. Switch to the Files tab, and select the README file to view your changes.
Next steps
Set up continuous integration & delivery or learn more about working with a Git repo.
Use Git and TFVC repos in the same project
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
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 main 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 main.
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 main . Branch policies enable you to:
Isolate work in progress from the completed work in your main branch.
Guarantee that changes build before they get to main.
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 main .
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. You can use the Azure DevOps CLI to discover a
list of projects. 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 main 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.
Azure DevOps Ser vices | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 - TFS
2017
Functional code search command filters extend your ability to refine your search across repositories beyond
what is documented in Get started with semantic search. To perform code searches, the Code Search
Marketplace extension must be installed for your organization or collection.
Prerequisites
You must install Code Search
For more information, see Install and configure search.
To use Code Search, you must have at least a Basic access.
Users granted Stakeholder access don't have access to code, and so don't have access to Code Search.
Users granted Stakeholder access for a private project can perform code searches, as they have Full Access to
the code.
When you're searching across the organization or collection, only results for which a project member has
access are listed.
NOTE
You can't search code in forked repositories.
USA GE EXA M P L E
Find all occurrences of the word QueueJobsNow in the path QueueJobsNow path:VisualStudio/Services/Framework
VisualStudio/Services/Framework and its subpaths.
Enclose the argument to the filter in double-quotes if it QueueJobsNow path:"VisualStudio/Windows Phones and
contains a space. Devices/Services"
Find all occurrences of the word QueueJobsNow in all files QueueJobsNow file:queueRegister*
where the filename starts with queueRegister.
USA GE EXA M P L E
Find all instances of "ToDo" comments in your code Select comment: and enter todo
Search in specific locations, such as within a particular path Use a search string such as
Driver path:MyShuttle/Server
USA GE EXA M P L E
Search for files by name or just by file extension Driver file:GreenCabs.cs . The search string
error ext:resx could be useful if you want to review all
error strings in your code. Even if your plain text search
string matches part of a filename, the file appears in the list
of found files. This search works without matching specific
file type functions.
TIP
Code Search remembers your last settings, such as the project and repository or path that you searched in. Clear the
checkboxes to search across all projects easily with the Clear all links when you want to search in a different scope. In the
results pane, Code Search highlights up to the first 100 hits or matches found in the target files.
Next steps
Search work items
Related articles
Get started with Search
Search artifacts and packages
Search work items
Search wiki
Search FAQs
Get started with Azure Repos and Visual Studio
3/18/2021 • 9 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 - TFS 2015 | VS
2017
Azure DevOps Server was formerly named Visual Studio Team Foundation Server (TFS).
Get up and running using Git with code already in Azure Repos. For more information on how to use Git from
Visual Studio or the command line, see Azure Repos Git tutorial.
If you don't have your code in an Azure Repos or Azure DevOps Server 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.
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
Visual Studio
Command Line
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
1. In Team Explorer, select Connect to open the Connect page, and then choose Manage Connections >
Connect to Project .
2. In Connect to a Project , select the repo you want to clone and select Clone . If you don't see your repo,
select Add Azure DevOps Ser ver to add a server that hosts a repo. You can filter the list to find your
repo.
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 Visual Studio Team Services is now Azure DevOps Services.
3. Verify the location of the cloned repo on your computer and select Clone .
Commit your work
Git branches isolate your changes from other work in the project. The recommended Git workflow uses a new
branch for every feature or fix you work on. You make commits in your local Git repository to save your changes
on that branch.
Visual Studio
Command Line
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
2. Right-click the main branch and choose New Local Branch From .
3. Enter a descriptive branch name for your work to remind you and others what kind of work is in the
branch. Select Create Branch .
4. Make changes to your files in the cloned repo. From the Team Explorer Home view, you can open Visual
Studio solutions in the repo or browse the repo contents using Show Folder View . Git keeps track of
changes made to your code both inside and outside of Visual Studio.
5. When you're satisfied with the changes, save them in Git using a commit. Open the Changes view from
Team Explorer by selecting the Home button and choosing Changes .
6. Enter a message that describes the commit, and select Commit All .
NOTE
If you have multiple files and you don't want to commit them all, you can right-click each file and choose Stage .
When you have staged all the files you would like to commit, select Commit Staged . Commit Staged replaces
Commit All when you manually stage your changes before the commit.
Visual Studio
Command Line
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
1. In Team Explorer, select Home and then choose Sync to open Synchronization .
You can also go to the Synchronization view from Changes by choosing Sync immediately after
making a commit.
If this push is your first to the repository, you'll see the following message:
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 Home and choosing Pull Requests .
4. In Pull Requests , you can view pull requests opened by you, assigned to you, and you can create new
pull requests. Select New Pull Request to open a web browser where you can create the new pull
request in the Azure Repos web portal.
5. Verify your branches. In this example, we want to merge the commits from the ReadMeFix branch into the
main branch. Enter a title and optional description, specify any reviewers, optionally associate any work
items, and then select Create .
For more information on pull requests, see the pull request tutorial.
Visual Studio
Command Line
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
You must have the Create repositor y permission, which is granted by default to project administrators. For
more information, see Set Git repository permissions.
Git command-line tools:
Install Git for Windows, which includes Git Credential Manager Core
Install Git for macOS and Linux.
For macOS and Linux, we recommend configuring SSH authentication
3. In the Create a new repositor y dialog, verify that Git is the repo type and enter a name for your new
repo. You can also 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. The .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 with no README or .gitignore files, you'll see instructions on how to
clone the repo to your computer. You'll also see instructions on how to push code in an existing repo
into the newly created one.
In this example, you created a README and a .gitignore. You'll now see an overview of the files in your
repo. 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've 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 Repositor y .
3. In the Create a new repositor y dialog, verify that Git is the repo type and enter a name for your new
repo. You can also 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. The .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 with no README or .gitignore files, you'll see instructions on how to
clone the repo to your computer. You'll also see instructions on how to push code in an existing repo
into the newly created one.
In this example. you created a README and a .gitignore. You'll now see an overview of the files in your
repo. 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.
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). Then, 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 into a new folder for you to work with. The download includes all
commits and branches from the repo.
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 into a new folder for you to work
with. This download includes all commits and branches from the repo.
Keep this command window open, as you'll use it in the following steps.
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 by entering the following command into the Git command window:
git push
6. Switch back to the web portal and select Histor y from the Code view to view your new commit. The
new repo has two commits. The first is the commit where the README and .gitignore were added when
the repo was created. The second is the commit you just made.
7. Switch to the Files tab and select the README file to view your changes.
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
3/6/2021 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 | TFS 2017 | TFS
2015
This article walks you through the steps to get a Visual Studio solution on your PC into an Azure DevOps 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.
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
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.
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 Ser vices Domain drop-down.
4. Enter your repository name and select Publish repositor y .
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 Repositor y 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. 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
Git preferences and settings in Visual Studio
3/6/2021 • 9 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018
Visual Studio allows you to configure and view common Git settings and preferences, such as your name and
email address, your preferred diff and merge tools, and more. These preferences and settings can be viewed and
configured in Team Explorer on either the Global Settings page (applies to all your repositories) or the
Repositor y Settings page (applies to the current repository).
Visual Studio allows you to configure two types of settings:
Git settings - The settings in this section correspond to Git settings that are saved in Git configuration files.
These settings can be viewed and modified in Visual Studio, but are managed by Git configuration files.
Visual Studio settings - The settings in this section configure Git-related settings and preferences that are
managed by Visual Studio.
This article shows you how to configure and view Git settings and preferences in Visual Studio, and where
applicable shows you the Git command line equivalents.
1. To configure Git settings in Visual Studio, choose Settings from Team Explorer.
2. Choose Global Settings or Repositor y 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 Repositor y 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
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
1. In Team Explorer, go to Settings . To set your user name and email at the global level, go to Global
Settings ; to set these at the repository level, go to Repositor y Settings .
2. Provide your user name and email, then choose Update to save.
Note that for Repositor y Settings , you'll first need to check Override global user name and email
settings .
Visual Studio
Command Line
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
Visual Studio
Command Line
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
Visual Studio
Command Line
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
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.
Clone an existing Git repo
3/18/2021 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 | TFS 2017 | TFS
2015 | VS 2017 | VS 2015
Create a complete local copy of an existing Git repository by cloning it. Cloning a repo downloads all commits
and branches in the repo. Cloning 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 assigns 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 tutorial using command line steps on Channel9.
If you need to clone a GitHub repo, you'll need to get the clone URL. Use 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
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
2. In Connect to a Project , select the repo you want to clone from the list and select Clone .
If you don't see your repo listed, filter the list to find it. You may need to add an Azure DevOps Server
where the repo is hosted. Select the Add Azure DevOps Ser ver 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 Visual Studio Team Services 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 aren't 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, as explained above.
2. Select Clone under Local Git Repositories and enter the URL for your Git repo. Your team or Git
hosting provider gives you this URL.
3. Select a folder where you want your cloned repo.
4. Select Clone to clone the repo.
Open a solution in Visual Studio from a cloned repo
1. Right-click on a repository in the Team Explorer Connect view and select Open .
In the Home view in Team Explorer, double-click your project solution file in the Solutions area. The solution
opens in Solution Explorer .
Next steps
Save work with commits
Import a Git repo
3/6/2021 • 7 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 Impor t repositor y 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 Impor t repositor y 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 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 Impor t repositor y .
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 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.
cd ..
rm -rf old-contoso-repo.git
Next steps
New to Git repos? Learn more
Learn more about Git in the Git tutorial
Import repositories from TFVC to Git
11/2/2020 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
Migrating to Git 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.
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
Connect to a project in Azure DevOps
3/6/2021 • 7 minutes to read • Edit Online
Azure DevOps Ser vices | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 - TFS
2013
Learn how to connect to a project to share code, build apps, track work, and collaborate with team members.
You can use any of the following clients:
Web portal
Visual Studio or Team Explorer
Eclipse/Team Explorer Everywhere
Android Studio with the Azure DevOps Services Plugin for Android Studio
IntelliJ with the Azure DevOps Services Plugin for IntelliJ
Visual Studio Code
A project defines a process and data storage in which you manage your software projects from planning to
deployment. When you connect to a project, you connect to an organization or project collection. One or more
projects may be defined within a collection. There must be at least one project. For more information, see About
projects and scaling your organization.
Prerequisites
If you don't have a project yet, create one.
If you need to add a team, see Add teams. If you don't have access to the project, get invited to the team.
From each of these clients, you can switch context to a different project and connect as a different user. If
you work remotely, configure your client to connect to an Azure DevOps Proxy Server.
To get started with a code base, set up Git or set up TFVC.
https://dev.azure.com/OrganizationName/ProjectName
http://ServerName/DefaultCollection/ProjectName
http://ServerName:8080/tfs/DefaultCollection/ProjectName
TIP
If you select Remember me , you won't have to enter your credentials the next time you connect.
From the project summary page, hover over a service and then choose the page you want. To choose
another project, choose the Azure DevOps logo.
Choose your project or team from the set of available links, or choose Browse to access all projects and
teams.
To learn more about each page and the tasks you can do, see Web portal navigation.
2. Select Add Azure DevOps Ser ver to connect to a project in Azure DevOps Services. Enter the URL to
your server and select Add .
3. Sign in using an account that is associated with an Azure DevOps project, either a valid Microsoft account
or GitHub account.
Use different Visual Studio credentials
You can run Visual Studio with credentials different from your current Windows user account. Find devenv.exe
under the Program Files (86) folder for your version of Visual Studio.
Select Shift and right-click devenv.exe, then select Run as different user .
3. For Visual Studio Team Foundation Ser ver , enter the name and port number for the Azure DevOps
Proxy Server. Select Use SSL encr yption (https) to connect .
Make sure you specify the port number that your administrator assigned to TFS Proxy.
To associate a file type with a compare or merge tool, see Associate a file type with a file-comparison tool or
Associate a file type with a merge tool.
What other clients support connection to Azure DevOps?
Besides connecting through a web browser, Visual Studio, Eclipse, Excel, and Project you can connect to a project
from these clients:
Visual Studio Code
Visual Studio Community
Eclipse: Team Explorer Everywhere
Azure Test Plans (formerly Test Manager)
Microsoft Feedback Client
Requirements and client compatibility
Some tasks or features aren't available when you connect to a later version of Azure DevOps Server than your
client supports. For more information, see client compatibility.
Determine your platform version
See Feedback and support.
Next steps
Learn more about how to:
Work in web portal
Work in Team Explorer
Work in Office Excel or Project
Troubleshoot connection
If all you need is a code repository and bug tracking solution, then start with the Get Started with Azure Repos
and Manage bugs.
To start planning and tracking work, see Get started with Agile tools to plan and track work.
Authentication overview
3/6/2021 • 3 minutes to read • Edit Online
Azure DevOps Ser vices | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 - TFS
2015
Choose a method to securely access the code in Azure Repos, Azure DevOps Server 2019, or Team Foundation
Server (TFS) Git repositories. Use these credentials with Git at a command prompt. These credentials also work
with any Git client that supports HTTPS or SSH authentication. Limit the scope of access and revoke these
credentials when they're no longer needed.
IMPORTANT
Azure DevOps no longer supports Alternate Credentials authentication since the beginning of March 2, 2020. If you're
still using Alternate Credentials, we strongly encourage you to switch to a more secure authentication method (for
example, personal access tokens). Learn more.
Azure DevOps Server was formerly named Visual Studio Team Foundation Server.
TIP
Using Visual Studio? Team Explorer handles authentication with Azure Repos for you.
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
Authentication comparison
A UT H EN T IC AT IO N
TYPE W H EN TO USE SEC URE? EA SE O F SET UP A DDIT IO N A L TO O L S
Personal access You need an easy to Very secure (when Easy Optional (Git
tokens configure credential using HTTPS) credential managers)
or need configurable
access controls
SSH You already have SSH Very secure Intermediate Windows users will
keys set up, or are on need the SSH tools
macOS or Linux included with Git for
Windows
NOTE
Current versions of Git for Windows include the Git credential manager as an optional feature during installation.
OAuth
Use OAuth to generate tokens for accessing REST APIs. The Accounts and Profiles APIs support only OAuth.
SSH authentication to generate encryption keys when you use Linux, macOS, or Windows running Git for
Windows and can't use Git credential managers or personal access tokens for HTTPS authentication.
Use SSH key authentication
3/20/2021 • 14 minutes to read • Edit Online
Azure DevOps Ser vices | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 - TFS
2015
Connect to your Git repos through SSH on macOS, Linux, or Windows to securely connect using HTTPS
authentication. On Windows, we recommended the use of Git Credential Manager Core or Personal Access
Tokens.
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 Azure DevOps 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 command will create a 2048-
bit RSA key for use with SSH. You can give a passphrase for your private key when prompted—this passphrase
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 command 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.
3. Copy the contents of the public key (for example, id_rsa.pub) that you generated into the Public 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 description 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. Also note that SSH keys stored in Azure
DevOps expire after five years. If your key expires, you may upload a new key or the same one to
continue accessing Azure DevOps via SSH.
5. Test the connection by running the following command: ssh -T git@ssh.dev.azure.com . If everything is
working correctly, you'll receive a response which says: remote: Shell access is not supported. If not,
see the section on Questions and troubleshooting.
3. Copy the contents of the public key (for example, id_rsa.pub) that you generated into the Public 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 description 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.
5. Test the connection by running the following command: ssh -T git@ssh.dev.azure.com . If everything is
working correctly, you'll receive a response which says: remote: Shell access is not supported. If not,
see the section on Questions and troubleshooting.
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 Visual Studio Team Services is now Azure DevOps Services.
SSH may display the server's SSH fingerprint and ask you to verify it. You should verify that the displayed
fingerprint matches one of the fingerprints in the SSH public keys page.
SSH displays this fingerprint when it connects to an unknown host to protect you from man-in-the-middle
attacks. Once you accept the host's fingerprint, SSH will not prompt you again unless the fingerprint changes.
$ git clone git@ssh.dev.azure.com:v3/fabrikam-fiber/FabrikamFiber/FabrikamFiber
Cloning into 'FabrikamFiber'...
The authenticity of host 'ssh.dev.azure.com (65.52.8.37)' can't be established.
RSA key fingerprint is SHA256:********************************************
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ssh.dev.azure.com,65.52.8.37' (RSA) to the list of known hosts.
Enter passphrase for key '/c/Users/jamal/.ssh/id_rsa':
remote: Azure Repos
remote: Found 127 objects to send. (50 ms)
Receiving objects: 100% (127/127), 56.67 KiB | 2.58 MiB/s, done.
Resolving deltas: 100% (15/15), done.
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
To prevent problems, Windows users should run a command to have Git reuse their SSH key passphrase.
A: Manually record the SSH key by running: ssh-keyscan -t rsa domain.com >> ~/.ssh/known_hosts
Q: How can I have Git remember the passphrase for my key on Windows?
A: Run the following command included in Git for Windows to start up the ssh-agent process in PowerShell or
the Windows Command Prompt. ssh-agent will cache your passphrase so you don't have to provide it every
time you connect to your repo.
start-ssh-agent.cmd
If you're using the Bash shell (including Git Bash), start ssh-agent with:
eval `ssh-agent`
Q: I use PuTTY as my SSH client and generated my keys with PuTTYgen. Can I use these keys with Azure
DevOps Services?
A: Yes. Load the private key with PuTTYgen, go to Conversions menu and select Expor t 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.
Q: How can I verify that the public key I uploaded is the same key as I have locally?
A: 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.
Q: How can I start using SSH in a repository where I am currently using HTTPS?
A: 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 .
Q: I'm using Git LFS with Azure DevOps Services and I get errors when pulling files tracked by Git LFS.
A: Azure DevOps Services currently doesn't support LFS over SSH. Use HTTPS to connect to repos with Git LFS
tracked files.
Q: How can I use a non-default key location, i.e. not ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub?
A: To use keys created with ssh-keygen in a different place than the default, perform these two tasks:
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.
Q: I have multiple SSH keys. How do I use different SSH keys for different SSH servers or repos?
A: 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:
remote: Public key authentication failed.
fatal: Could not read from remote repository.
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_private_key maps to %USERPROFILE%\.ssh\your_private_key,
# e.g. C:\Users\<username>\.ssh\your_private_key.
# Most common scenario: to use the same key across all hosted Azure DevOps
# organizations, add a Host entry like this:
Host ssh.dev.azure.com
IdentityFile ~/.ssh/your_private_key
IdentitiesOnly yes
# This model will also work if you still use the older SSH URLs with a
# hostname of vs-ssh.visualstudio.com:
Host vs-ssh.visualstudio.com
IdentityFile ~/.ssh/your_private_key
IdentitiesOnly yes
# Less common scenario: if you need different keys for different organizations,
# you'll need to use host aliases to create separate Host sections.
# This is because all hosted Azure DevOps URLs have the same hostname
# (ssh.dev.azure.com), so SSH has no way to distinguish them by default.
#
# Imagine that we have the following two SSH URLs:
# * git@ssh.dev.azure.com:v3/Fabrikam/Project1/fab_repo
# * For this, we want to use `fabrikamkey`, so we'll create `devops_fabrikam` as
# a Host alias and tell SSH to use `fabrikamkey`.
# * git@ssh.dev.azure.com:v3/Contoso/Project2/con_repo
# * For this, we want to use `contosokey`, so we'll create `devops_contoso` as
# a Host alias and tell SSH to use `contosokey`.
#
# 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_fabrikam
HostName ssh.dev.azure.com
IdentityFile ~/.ssh/private_key_for_fabrikam
IdentitiesOnly yes
Host devops_contoso
HostName ssh.dev.azure.com
IdentityFile ~/.ssh/private_key_for_contoso
IdentitiesOnly yes
#
# Then, instead of using the real URLs, tell Git you want to use these URLs:
# * git@devops_fabrikam:v3/Fabrikam/Project1/fab_repo
# * git@devops_contoso:v3/Contoso/Project2/con_repo
#
# At the end of the file, you can put global defaults for other SSH hosts you
# may connect to. 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 *
# 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_private_key maps to %USERPROFILE%\.ssh\your_private_key,
# e.g. C:\Users\<username>\.ssh\your_private_key.
# Say your on-premises Azure DevOps Server instance has SSH URLs like this:
# ssh://someHost:22/someCollection/some_project/_git/some_repo
# Add the following Host section:
Host someHost
IdentityFile ~/.ssh/your_private_key
IdentitiesOnly yes
# At the end of the file, you can put global defaults for other SSH hosts you
# may connect to. 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 *
Q: How do I fix errors that mention "no matching key exchange method found"?
A: Git for Windows 2.25.1 shipped with a new version of OpenSSH which removed some key exchange
protocols by default. Specifically, diffie-hellman-group14-sha1 has been identified as problematic for some
Azure DevOps Server and TFS customers. You can work around the problem by adding the following to your
SSH configuration ( ~/.ssh/config ):
Host <your-azure-devops-host>
KexAlgorithms +diffie-hellman-group14-sha1
Replace <your-azure-devops-host> with the hostname of your Azure DevOps or TFS server, like
tfs.mycompany.com .
Q: What notifications may I receive about my SSH keys?
A: Whenever you register a new SSH Key with Azure DevOps Services, you will receive an email notification
informing you that a new SSH key has been added to your account.
Q: What do I do if I believe that someone other than me is adding SSH keys on my account?
A: If you receive a notification of an SSH key being registered and you did not manually upload it to the service,
your credentials may have been compromised.
The next step would be to investigate whether or not your password has been compromised. Changing your
password is always a good first step to defend against this attack vector. If you’re an Azure Active Directory user,
talk with your administrator to check if your account was used from an unknown source/location.
Q: What do I do if I'm still prompted for my password and GIT_SSH_COMMAND="ssh -v" git fetch shows
no mutual signature algorithm ?
A: Some Linux distributions, such as Fedora Linux, have crypto policies that require stronger SSH signature
algorithms than Azure DevOps supports (as of January 2021). There's an open feature request to add this
support.
You can work around the issue by adding the following code to your SSH configuration ( ~/.ssh/config ):
Host ssh.dev.azure.com
PubkeyAcceptedKeyTypes=ssh-rsa
Replace ssh.dev.azure.com with the correct host name if you use Azure DevOps Server.
Use Git Credential Manager Core to authenticate to
Azure Repos
3/6/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 | TFS 2017 | TFS
2015 | VS 2017 | VS 2015
Git Credential Manager Core simplifies authentication with your Azure Repos Git repositories. Credential
managers let you use the same credentials that you use for the Azure DevOps Services web portal. Credential
managers support multi-factor authentication through Microsoft account or Azure Active Directory (Azure AD).
Besides supporting multi-factor authentication with Azure Repos, credential managers also support two-factor
authentication with GitHub repositories.
Azure Repos provides IDE support for Microsoft account and Azure AD authentication through the following
clients:
Team Explorer in Visual Studio
IntelliJ and Android Studio with the Azure Repos Plugin for IntelliJ
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 to your repositories.
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.
A token can be revoked through Azure Repos.
Getting help
You can open and report issues with Git Credential Manager Core on the project GitHub.
Azure Repos Git tutorial
3/18/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 - TFS 2015 | VS
2017 | VS 2015
Azure DevOps Server was formerly named Visual Studio Team Foundation Server (TFS).
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
Ignore file changes with Git
3/6/2021 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 aren't 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
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
Visual Studio automatically creates a .gitignore file in your repo when you create new repo for your project.
Git applies .gitignore to the folder and any child folders where it's located. We recommend you place your
.gitignore in the root folder of your repo to prevent confusion.
Customize your .gitignore
Modify your .gitignore to include files types, paths, and file patterns in your repo. Git starts ignoring these files
as soon as you update .gitignore. If others on your team need the same set of ignored files, be sure to commit
your changes.
Visual Studio
Command Line
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
You can edit your .gitignore file for your repo by going to the Settings view in Team Explorer, then selecting
Repositor y Settings . Select Edit for your .gitignore.
Each line in the .gitignore excludes a file or set of files that match a pattern. The full gitignore syntax is very
flexible. Here are some examples of the most common entries:
NOTE
Windows users: All file paths in the .gitignore file use a forward slash separator, not a backslash.
This approach is useful for ignoring entire file types you don't want to ever commit, such as compiled binaries.
Instead, you can use the following parameters. These parameters are primarily for marking files that should not
be changed by developers.
To disable change tracking:
3. Commit the removal of the file and the updated .gitignore to your repo.
Next steps
Review history
Manage and store large files in Git
11/2/2020 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 Azure DevOps Server or 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.
How dates work in Git
3/6/2021 • 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
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
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
3/6/2021 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 directory 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
maximum length of 260 255 characters 255 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 versions cap it at 1016
must be less than 260 characters. Some file
characters, and the systems support 1016 as
directory name must be max path
less than 248 characters.
Encoding support
NOTE
The encoding support described in this section is supported in Azure DevOps Server 2019.1 and higher.
Microsoft has added support for UTF-16 and UTF-32 encoding via the web pushes endpoint. This means that we
will preserve the encoding type so you don't have to rewrite your files as UTF-8. You will also see a warning
when you try to save a file that is not UTF encoded via the web (which only supports UTF encoding).
The following screenshot shows an example of the dialog that you see when you introduce encoding changes by
a web push.
Create a new Git repo
3/20/2021 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 - 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.
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
Create a repo
Create a repo from a new solution
Create a repo from an existing solution
Create a repo in an empty folder
Connect a local repo to a remote
From a new solution
Create a new Git repo for your new Visual Studio solution by selecting Create new Git repositor y when
creating the solution:
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
Get started with Git from the command line
3/6/2021 • 2 minutes to read • Edit Online
Azure Repos
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
Refer to the list of install commands for the most up to date instructions for your Linux distribution.
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.
$ az repos create --name FabrikamApp
[
{
"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
Azure Repos Plugin for IntelliJ IDEA and Android
Studio
3/6/2021 • 7 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
To install Git for macOS and Linux, see git-scm.com.
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 Visual Studio Team Services 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 Repositor y .
3. In the Create a new repositor y 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 Ear th 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 Eclipse
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 Repositor y 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
Share your code in Git using Xcode
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
Git repository settings and policies
4/17/2021 • 12 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
1. From your web browser, open the project for your organization in Azure DevOps and choose Project
settings , Repositories , and select your repository.
2. Select Settings to view and configure your repository settings.
3. Select Policies to view and configure project level and cross-repo policies.
All repositories settings and policies
Admins have access to a number of settings and policies to customize your project.
Default branch name preference
You can choose any legal branch name to use when a repository is initialized, or change it later if necessary. You
can access the setting in two ways:
Organization settings - From the DevOps page, select your project > Organization settings >
Repositories , turn on Default branch name for new repositories , and type your default branch
name.
Project settings - From the project page, select Project settings > Repositories > Settings , turn on
Default branch name for new repositories , and type your default branch name.
If you don't enable this feature, your repositories will be initialized with the Azure Repos default name, main.
Cross-repo branch policy administration
You can set policies on a specific branch or the default branch across all repositories in their project. For
example, an admin could require two minimum reviewers for all pull requests made into every main branch
across every repository in their project. You can find the Add branch protection feature in the Repos Project
Settings.
Add a policy to block commits based on the commit author email
You can set a push policy to prevent commits from being pushed to a repository for which the commit author
email does not match the provided pattern.
1. From your web browser, open the project for your organization in Azure DevOps and choose Project
settings , Repositories , and select your repository.
2. Select Options and Policies to view and configure your repository settings.
1. From your web browser, open the project for your organization in Azure DevOps and choose the gear
icon, Version Control , and select your repository.
2. Select options to view and configure your repository settings.
1. From your web browser, open the project for your organization in Azure DevOps and choose the gear
icon, Version Control , and select your repository.
2. Select options to view and configure your repository settings.
Forking
Controls whether users are able to create new server-side forks. Disabling this setting will not alter existing
forks.
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.
For instructions on configuring this policy using Azure CLI, see View and edit repository settings.
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.
Maximum file size
Large files checked into Git remain in the repository forever, dragging down clone times and increasing disk
usage. We have suggestions for helping you manage large files.
This setting gives administrators a way to block files over a certain size from entering the repository. If a push
contains a new or updated file larger than the limit configured in this setting, that push will be blocked. The user
will have to rewrite their unpushed history to remove the large file and try the push again.
For instructions on configuring this policy using Azure CLI, see View and edit repository settings.
Related articles
Set branch policies
Default Git permissions (Security)
Set permissions (Security)
Set Git repository permissions
4/17/2021 • 9 minutes to read • Edit Online
Azure DevOps Ser vices | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 - TFS
2013
You grant or restrict access to repositories to lock down who can contribute to your source code and manage
other features. You can 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.
NOTE
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.
For guidance on who to provide greater permission levels, see Grant or restrict access using permissions.
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 Azure DevOps.
You must be a member of the Project Administrators Group or have your Manage permissions set to
Allow for Git repositories.
To contribute to the source code, you must be granted Basic access level or greater. Users granted Stakeholder
access for private projects have no access to source code. Users granted Stakeholder access for public projects
have the same access as Contributors and those granted Basic access. To learn more, see About access levels.
To contribute to the source code, you must be granted Basic access level or greater. Users granted Stakeholder
access have no access to source code. To learn more, see About access levels.
Permission
Readers
Contributors
Build Admins
Project Admins
Read (clone, fetch, and explore the contents of a repository); also, can create, comment on, vote, and
Contribute to pull requests
️
✔
️
✔
️
✔
️
✔
Edit policies , Force push (rewrite histor y, delete branches and tags) , Manage permissions , Remove
others' locks
️
✔
Bypass policies when completing pull requests (not set for any security group)
Permission
Contributors
Build Admins
Project Admins
Branch Creation : At the repository level, can push their changes to branches in the repository. Does not
override restrictions in place from branch policies. At the branch level, can push their changes to the branch and
lock the branch.
️
✔
️
✔
️
✔
Contribute : At the repository level, can push their changes to branches in the repository. Does not override
restrictions in place from branch policies. At the branch level, can push their changes to the branch and lock the
branch.
️
✔
️
✔
️
✔
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.
️
✔
️
✔
️
✔
Administer : Delete and rename repositories: If assigned to the top-level Git repositories entry, can add
additional repositories. At the branch level, users can set permissions for the branch and unlock the branch. The
Administer permission set on an individual Git repository does not grant the ability to rename or delete the
repository. These tasks require Administer permissions at the Git repositories top-level.
️
✔
Rewrite and destroy histor y (force push) : Can force an update to a branch and delete a branch. A force
update can overwrite commits added from any user. Users with this permission can modify the commit history
of a branch.
️
✔
By default, the Project Collection Build Service can read from all repositories. Any pipeline which runs within the
project collection scope can potentially read any repository in the organization or collection. To remove this
permission for a repository, change the Read permission to Deny for the Project Collection Build Service.
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.
NOTE
You may not be able to find a user from a permissions page or identity field if the user hasn't been added to the
project—either by adding it to a security group or to a project team. Also, when a user is added to Azure Active
Directory or Active Directory, there can be a delay between the time they are added to the project and when they
are searchable from an identity field. The delay can be between 5 minutes to 7 days.
Otherwise, choose a specific repository and choose the security group whose permissions you want to
manage.
5. Choose the setting for the permission you want to change.
Here we grant permissions to the Contributors group to (3) Create repositor y .
6. When done, choose Save changes .
Individual repositories inherit permissions from the top-level Git Repositor y security settings. Branches inherit
permissions from assignments made at the repository level.
1. Open the web portal and choose the project where you want to add users or groups. To choose another
project, see Switch project, repository, team.
2. Choose the gear icon to open the administrative context.
3. Choose Version Control .
4. To set the set the permissions for all Git repositories for a project, (1) choose Git Repositories and then
(2) choose the security group whose permissions you want to manage.
Otherwise, choose a specific repository and choose the security group whose permissions you want to
manage.
5. Choose the setting for the permission you want to change.
6. When done, choose Save changes .
2. Change one or more permissions. To grant a permissions, change Not Set to Allow . To restrict
permissions, change Allow to Deny .
3. When done, navigate away from the page. The permission changes are automatically saved for the
selected group.
NOTE
You may not be able to find a user from a permissions page or identity field if the user hasn't been added to the
project—either by adding it to a security group or to a project team. Also, when a user is added to Azure Active
Directory or Active Directory, there can be a delay between the time they are added to the project and when they
are searchable from an identity field. The delay can be between 5 minutes to 7 days.
2. When done, navigate away from the page. The permission changes are automatically saved for the
selected group.
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.
To learn about inheritance, see About permissions and groups, Inheritance and security groups.
NOTE
This change does not introduce any behavior changes. Users that were formerly granted Allow for Exempt from policy
enforcement are granted Allow for both new permissions, so they'll be able to both override completion on PRs and
push directly to branches with policies.
Related articles
Grant or restrict access using permissions
Default permissions and access
Permissions and groups reference
Tf git permission command-line tool
Security REST API commands
Create a README for your repo
3/6/2021 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 | TFS 2017 | TFS
2015
Your Git repo should have a readme file so that viewers know what your code does and how they can get
started using it. Your readme should speak to the following audiences:
Users that just want to run your code
Developers that want to build and test your code. Developers are also users.
Contributors that want to submit changes to your code. Contributors are both developers and users.
Write your readme in Markdown instead of plain text. Markdown makes it easy to format text, include images,
and link as needed to additional documentation from your readme.
Here are some great readmes that use this format and speak to all three audiences, for reference and
inspiration:
ASP.NET Core
Visual Studio Code
Chakra Core
Create an intro
Start your readme off with a short explanation describing your project. Add a screenshot or animated GIF in
your intro if your project has a user interface. If your code relies on another application or library, make sure to
state those dependencies in the intro or right below it. Apps and tools that run only on specific platforms should
have the supported operating system versions noted in this section of the readme.
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 | TFS 2017 | TFS
2015
Remove unused Git repos from your project when they are no longer needed.
TIP
Consider renaming the repo and locking its default branch instead of removing it. The commit history of the repo will be
lost when it is deleted.
IMPORTANT
You cannot remove a repo if it is the only Git repo in the Project. If you need to delete the only Git repo in a Project,
create a new Git repo first, then delete the repo.
You must have Delete Repository permissions to delete a repo from a project.
NOTE
The steps in this article show how to delete a Git repo from your project. If you want to delete the entire project, see
Delete a project.
3. Select the name of the repository from the Repositories list, choose the ... menu, and then choose
Delete repositor y .
4. Confirm the deletion of the repository by typing the repo's name and selecting Delete .
1. Select the settings icon in the web to bring up the project administration page and choose Version
Control .
2. Select the Git repository to remove from the list shown and select the ... next to the name. Choose Delete
Repositor y .
NOTE
If the Repositories pane is not expanded, select > to expand it and display the list of repositories.
3. Confirm the deletion of the repository by typing the repo's name and selecting Delete .
Rename a Git repository in your project
4/17/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 | TFS 2017 | VS
2017 | VS 2015
You can rename a Git repository in a project from your web browser. After you rename the repo, each member
of your team should take a few steps to re-enable their dev machines to connect to the repo on the server.
NOTE
The steps in this article refer to Azure Repos and TFS 2017 and higher. For TFS 2015, see Rename a Git repository in TFS
2015.
4. Rename the repository by typing the repo's new name and selecting Rename .
1. Open the project administration page while working in your project on the web and select Version
Control .
2. Select the repo you want to rename under Git repositories on the left and select .... Select Rename
repositor y... from the menu.
NOTE
If the Repositories pane is not expanded, select > to expand it and display the list of repositories.
3. Enter a new repo name in the Repositor y name field in the dialog, then select Rename .
1. Select Clone in the upper-right corner of the Code window and copy the Clone URL .
Update your remote in Visual Studio 2015 or 2017
1. Connect to the repo.
Update your remote in older versions of Visual Studio from the command prompt
If you use an older version of Visual Studio or work with Git from the command prompt:
1. Open the Git command prompt.
2. Go to the local repository and update the remote to the URL you copied from the remote repo.
git remote set-url origin {URL_you_copied_from_the_remote_repo}
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 | TFS 2017
Quickly find and navigate to a file or folder in your Git repository using the path control in the Files page.
Usage
While browsing your Git repository, start typing in the path control box to search for the file or folder you are
looking for. The interface lists the results starting from your current folder followed by matching items from
across the repo.
Hotkey navigation
Launch the Find a File experience from the keyboard with the t shortcut from the Files or Commits pages in
the Repos view. Use the up and down arrows to cycle through the results, and click or press Enter to open a
result. Press Esc to close the Find a File experience.
Launch the Find a File experience from the keyboard with the t shortcut from the Files or Histor y tabs in the
Files page. Use the up and down arrows to cycle through the results, and click or press Enter to open a result.
Press Esc to close the Find a File experience.
Move Git repositories to another project with full-
fidelity history
3/6/2021 • 3 minutes to read • Edit Online
If you're planning to consolidate multiple Azure DevOps projects into one, you're probably wondering:
What to do with all the repositories?
Move or merge them?
Keep history or just the tip of the iceberg?
In this article you will learn how to move your Git repositories to another project, with full-fidelity history.
How do I move?
You have two options as outlined below. Import functionality is easier, but is only available in Azure DevOps
Services and TFS 2017 Update 1 and above.
Use Import Git repository functionality
Using the Import Repository feature, you can import a Git repository to your team project from Team
Foundation Server (TFS), Azure Repos or any other Git source code provider like GitHub. Review the import
repository documentation for more details.
Manually migrate the Git repo in five easy steps:
Create an empty Git repo.
From the code explorer, click on the repo name. Choose New Repositor y from the list, select Git as the type,
and give it a name.
Once the repo is created, you are presented with step-by-step instructions to quickly get started. Copy the
Clone URL to your clipboard.
IMPORTANT
Clear the Automatically create links for work items mentioned in a commit comment if you are importing from
a different project collection or a foreign git repository. Azure DevOps will otherwise associate the commits to existing
work items of unrelated team projects in the team project collection.
Command Line:
git clone --mirror https://demo-fabrikam.visualstudio.com/DefaultCollection/Fabrikam/_git/MigrationDemo
As shown, the clone --mirror is redundant in this case, as the remote repository is bare. It is used here as a safe
and easy way to set up the remote.
Push the repo
Run the git push command to push the local changes to the remote (target) repo.
The --mirror option is used with both the clone and push command. The option ensures that all branches and
other attributes are replicated in the new repo.
Validate the new repository
Switch to the Azure DevOps web portal and validate the new repository and the history in the CODE hub.
Verify that all your branches were moved over to the new repo.
Configure the new repo
Verify that the permissions and policies are correctly configured for the new repo. You can configure the security
after step 1, or at this stage. Reconfigure your builds to connect with the new repo. Lastly, notify users of the
original repo to update their remotes in Visual Studio, or running the git remote set-url origin command.
IMPORTANT
Remember to clean up the original project by either deleting the repo (be careful, there's no undo) or locking the branches
so that no one accidentally keeps updating it.
For detailed information on planning your team project collections and team projects, refer to the TFS Planning,
Disaster Avoidance and Recovery, and TFS on Azure Iaas Guide.
Authors: Jesse Houwing, Mike Fourie, and Willy Schaub | Connect with the authors and ALM DevOps
Rangers
(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.
Learn how to remove a large binary from your Git
history to manage the size of cloned repositories
4/17/2021 • 8 minutes to read • Edit Online
Git has gained much popularity in recent years as a distributed source code repository that lets users work with
the full repository while in a disconnected state. The benefits of git are well-documented, but what happens if
you need to "roll back the clock" on the primary repository? Doing so is not so intuitive and requires elevated
permissions, as you might expect for something that affects every single user of the repository.
So how can you roll back the central repository safely?
Problem Scenario
Imagine that you commit a large file, such as a video, to your git server. In a traditional source code system, it is
convenient to store everything in one place and then pull down what you need. However, with git, the entire
repository is cloned down to each user's local computer. With a large file, every single user on the project will
need to download the large file(s), too. With each subsequent large file committed to the server, the problem
only grows, until the repository is too large to be efficient for its users. To make matters worse, even if you
remove the offender from your local repository and recommit, the file will still exist in the repository's history,
which means that it will still be downloaded to everyone's local computer as part of the history.
To fix this, you have to start at the source, which, in this case, is the server repository. Ask the team to stop
pushing to the repository, but if additional pushes happen during this process, you will have to account for
them, too, so as not to lose any data.
git log
Alternatively, you can get the SHA hash from viewing the branch history in the Visual Studio Team Explorer.
The -i switch provides a little extra safety, because it will bring up the history in an editor (My implementation
of git on the command line in Windows brings up the classic vi editor, which you may remember if you've
worked with a Unix-based system.)
5. For our example, you would enter:
6. Once the editor comes up, remove all of the 'pick' lines except for the branch you want to keep as your new
head. When everything looks as you want it, in vi, type ":w<enter>" to save or "!q<enter>" to exit without
saving.
You will be changing the line(s) that you no longer want
7. Change " pick " to " drop " as shown, then type " :w " (in vi) to save and " :q! " to start the rebase
Now type git log again - the offending branch should be absent from the log. If it is, you are ready for the final
step, which requires project admin permissions.
git log
Notice that the commit for the large video is now gone from the local repo
8. Type: git push --force
This command will force your repository to overwrite the repository on the server.
Use with caution, as you can easily lose data on the ser ver!!
Notice that you must authenticate to the server for this to work
If you are using Azure Repos, you may need to set up an alternate credential that doesn't use special characters
(such as the "@" in an email address). To do this, follow the instructions here.
Now, the branch will be permanently gone from the server, and subsequent clones and syncs by project team
members will not download the large files you were trying to remove. Users will need to pull down from the
server in order to make sure that they are in sync with the new server repo state.
Do's
Do commit changes frequently. You can always fix them up later with a squash or rebase.
Do use branches to isolate your changes. Branches are cheap and private, and merging is simple. You can
also back up changes on a branch by pushing it to the server.
Do use a naming convention when publishing topic branches. Name the branch " users/<alias>/<branchname>
". This will help group your branches and make it easy for others to identify the "owner".
Do remember to push your changes. Commit != Checkin . (Commit + Push) == Checkin .
Do consider using .gitignore for large binaries so that they aren't added to the repo in the first place - more
information here.
Do consider using NuGet or TFS version control to store your large binaries.
Don'ts
Don't rebase after pushing. Rebasing pushed commits in git can be bad because it forces everyone else in the
repo to rebase their local changes - and they won't be happy if they need to do this. Rebasing pushed
commits on your own personal branch, even if pushed, isn't a significant deal unless other people are pulling
those commits.
Don't commit binaries to your repo. Git doesn't compress binary files the way that TFVC does, and because
all repos have all of the history, committing binary files means permanent bloat.
Summary
Sometimes, undesirable elements, such as large files, are added to a repository and need to be removed in
order to keep the repository clean and lightweight. You can do this by getting your local repository in order
using the git rebase command, then using the git push --force command to overwrite the server repository
with your local repository.
Authors: Edward Fry and Jesse Houwing | Connect with the authors and ALM | DevOps Rangers 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.
About branches and branch policies
3/18/2021 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 main branch
Guarantee changes build before they get to main
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
Require pull requests to make any changes on these branches. Developers pushing changes directly to the
protected branches will have their pushes rejected.
Keep your branch strategy simple by building your strategy from these three concepts:
1. Use feature branches for all new features and bug fixes.
2. Merge feature branches into the main branch using pull requests.
3. Keep a high quality, up-to-date main branch.
A strategy that extends these concepts and avoids contradictions results in a version control workflow for your
team that is consistent and easy to follow.
Adopt a branching strategy
How to configure branch policies
Branch permissions
Require branch folders
Configure a branch policy for an external service
Video Overview
https://channel9.msdn.com/series/Team-Services-Git-Tutorial/Git-Tutorial-Branches/player
In this screenshot, you can see a new branch that was 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're 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're 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 brings the files' state 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.
Distributed version control systems like Git give you flexibility in how you 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. You can 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 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
feature/feature-name
feature/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 main branch in a pull request, unlike the feature branches. Create as many release
branches as you need. Keep in mind that each active release branch represents another version of the code you
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 main branch when 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 main 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 commit as a release. Tags are useful for marking
points in your history as important. Tags introduce extra steps in your workflow that aren't necessary if you're
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 main branch.
Cherry-pick bug fixes in the deployment branch back to the main branch. Use the same steps as porting
changes from a release branch.
An exception to this recommendation is if you're using a form of continuous deployment. Use Azure Pipelines
when working with continuous deployment to promote builds from your main branch to your deployment
targets.
Videos
Create a new Git branch
3/18/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 won't 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 dropdown list next to the branch name and then
selecting New branch .
1. View your repo's branches by selecting Repos > Branches while viewing your repo on the web.
3. In the Create a branch dialog box, 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
3/18/2021 • 2 minutes to read • Edit Online
This article describes how to delete a Git branch by using two different methods: in Visual Studio and from the
command line.
NOTE
Deleting a branch in your local repo doesn't remove the branch on the remote.
Browser
Visual Studio
Command Line
1. View your repo's branches by selecting Repos > Branches while viewing your repo on the web.
2. Select the More options button at the end of the row of the branch you want to delete.
The default branch is the first branch that Git will check out on a fresh clone. Also, pull requests target this
branch by default.
We'll walk through the process of changing the default branch. We'll also cover additional things you must
consider and update when making this change. Finally, we'll look at a tool for easing the transition.
Configure your Git repo to use a different default branch to merge code into when your team creates new pull
requests. You can use a branch other than main for new changes or change your main line of development in
your repo. To change the default branch name for new repositories, see All repositories settings and policies.
1. Navigate to your repository and select Branches .
2. Select the desired new default branch. You need at least two branches in order to change the default. If
there's only one, it will already be the default branch. In that case, you must create a second one in order
to change the default.
3. Select the ... beside the desired branch and choose Set as default branch .
4. Once you've set the new default branch, you may delete the previous one if desired.
1. Select the settings button in your project open to open the project administration page.
5. Once you've set the new default branch, you may delete the previous one if desired.
Choosing a name
Git 2.28 added the ability to choose an initial branch name. At the same time, Azure Repos, GitHub, and other Git
hosting providers added the ability to choose a different initial branch name. Previously, the default branch was
almost always named master . The most popular alternative name is main . Less common options include
trunk and development . Absent any restrictions from the tools you use or team you're on, any valid branch
name will work.
Updating other systems
When you change to a different default branch, other parts of your workflow may be affected. You'll need to take
these parts into account when you're planning a change.
Pipelines
Update the CI triggers for all pipelines. Designer pipelines can be edited in the web. YAML pipelines can be
edited in their respective repositories.
In-flight pull requests
Retarget each open pull request to the new default branch.
Existing clones
New clones of the repository will get the new default branch. After the switch, everyone with an existing clone
should run git remote set-head origin -a (replacing origin with the name of their remote if it's something
else) to update their view of the remote's default branch. Future new branches should be based on the new
default.
Incoming links
Some bookmarks, documents, and other non-code files which point to files in Azure Repos will need to be
updated. The branch name for a file or directory can appear in the URL.
If a URL contains a querystring for version (e.g. &version=GBmybranchname ), then that URL should be updated.
Fortunately, most links to the default branch will not have a version segment and can be left as-is. Also, once
you delete the old default branch, attempts to navigate to it will be taken to the new default anyways.
Temporary mirroring
A Git repository can only have one default branch. However, for a period of time, you can set up ad-hoc
mirroring between your old default and your new default. This way, if your end users continue pushing to the
old default, they won't need to re-do the work on their end. We'll use Azure Pipelines to set up this temporary
mirroring.
NOTE
This section uses language which is at odds with Microsoft's perspective. Specifically, the word master appears in several
places consistent with how it's been used in Git. The purpose of this topic is to explain how to switch to more inclusive
language, such as main . Avoiding all mention of master would make the directions much harder to understand.
NOTE
These instructions are not fool-proof, and your repository setup may require additional changes such as loosening
permissions and policies.
WARNING
If the old and new default branches are both updated before this pipeline runs, then the pipeline won't be able to mirror
the changes. Someone will have to manually merge the old default branch into the new default branch to get it running
automatically again.
1. For all existing CI builds, update them to trigger against your new default branch instead of the old one.
2. Grant the build identity Contribute permission to your repo. Navigate to Project Settings >
Repositories > (your repo) > Permissions . There may be up to two identities, one for the project
collection build service and the other for the project build service. Make sure the Contribute permission
says Allow .
3. If the new default branch has branch policies, also grant the build identity the Bypass policies when
pushing permission. This is a security risk since a malicious user could craft a pipeline to sneak code into
a repository in your project. When mirroring isn't needed anymore, be sure to remove this permission.
4. Add a new file, mirror.yml to your repository in the new default branch. In this example, we assume the
old default branch was master and the new one is main . Update the triggering branches and the
git push line if your branch names are different.
trigger:
branches:
include:
- master
- main
5. Create a new pipeline, choosing "Azure Repos Git" and "Existing Azure Pipelines YAML file" in the wizard.
Choose the mirror.yml file you added in the previous step. Save and run the pipeline.
Troubleshooting
This pipeline will run every time there's a push to master or to main . It will keep them in sync as long as new
commits don't arrive on both branches simultaneously.
If the pipeline begins failing with an error message like "Updates were rejected because a pushed branch tip is
behind its remote", someone will have to merge the old branch into the new branch by hand.
1. Clone the repository and cd into its directory.
2. Checkout the new default branch with git checkout main (if main is your new default branch).
3. Create a new branch for integrating the two branches with git checkout -b integrate .
4. Merge the old default branch with git merge master (if master is your old default branch).
5. Push the new branch, then open and complete a pull request into the new default branch.
6. The mirroring pipeline should then take care of mirroring the merge commit back to the old default.
Forks
4/17/2021 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018
Forks are a great way to isolate experimental, risky, or confidential changes from the original codebase. 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, 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. Once you're ready to share those changes, it's easy to use pull requests to push the changes back to the
original repository.
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.
Share 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.
NOTE
To enable forking at the organization level, go to Project Settings > Repositories , then select the repository and
Options next to the Security tab to turn on forks.
For some versions this might require enabling forking as a Preview Feature, see User settings > Preview Features ,
then select For this organization from the drop-down, and make sure Git Forks is turned on.
NOTE
You must have the Create Repository permission in your chosen project to create a fork. We recommend you create a
dedicated project for forks where all contributors have the Create Repository permission. For an example of granting this
permission, see Set Git repository permissions.
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
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
5. Select Save and the new remote is added and displayed in the repository settings.
Visual Studio
Command Line
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
In Visual Studio, you can use the Synchronization page to fetch and rebase.
1. Open the Synchronization page in Team Explorer.
2. Fetch from upstream .
3. Open the Branches page in Team Explorer. Make sure main is checked out.
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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. You can use a branch other than main for new changes or change your main line of development in
your repo. To change the default branch name for new repositories, see All repositories settings and policies.
1. Navigate to your repository and select Branches .
2. Select the desired new default branch. You need at least two branches in order to change the default. If
there's only one, it will already be the default branch. In that case, you must create a second one in order
to change the default.
3. Select the ... beside the desired branch and choose Set as default branch .
4. Once you've set the new default branch, you may delete the previous one if desired.
1. Select the settings button in your project open to open the project administration page.
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
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.
Select the ... button. Select Branch policies from the context menu.
Configure policies on the Settings page. See the following sections for descriptions of each policy type.
Configure your policies in the Policies page. See the following sections for descriptions of each policy type.
Select Save changes to apply your new policy configuration.
If Requestors can approve their own changes isn't selected, the creator of the pull request can still vote
Approve on their pull request, but their vote won't count toward the Minimum number of reviewers .
If any reviewer rejects the changes, the pull request can't finish unless you select Allow completion even if
some reviewers vote to wait or reject .
You can reset code reviewer votes when new changes are pushed to the source branch. Select Reset code
reviewer votes when there are new changes .
When the required number of reviewers approve the pull request, it can finish.
NOTE
The Requestors can approve their own changes setting only applies to the Require a minimum number of
reviewers policy. It doesn't affect other policies such as Automatically include code reviewers. For example, Jamal
Hartnett creates a pull request with the following policies configured:
Minimum number of reviewers requires two reviewers.
Requestors can approve their own changes isn't 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.
The pull request still requires two additional Approve votes to satisfy the Minimum number of reviewers policy, since
his vote doesn't count toward that policy.
For more information on working with pull request comments, see Pull requests - leave comments.
Basic merge (no fast-for ward) - creates a merge commit in the target whose parents are the target and
source branches.
Squash merge - creates a linear history with 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.
Rebase and fast-for ward - creates a linear history by replaying source commits onto the target branch
with no merge commit.
Rebase with merge commit - replays the source commits onto the target and still creates a merge
commit.
Enforce a merge strategy
Maintain a consistent branch history by enforcing a merge strategy when a pull request finishes. Select Enforce
a merge strategy and pick an option to require that pull requests merge using that strategy.
No fast-for ward merge - This option 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. Build policies reduce breaks and keep your test results passing. Build policies help
even if you're using continuous integration (CI) on your development branches to catch problems early.
If a build validation policy is enabled, a new build is queued when either a new pull request is created, or if
changes are pushed to an existing pull request targeting the 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 pipeline. If you don't have one, see Create a build
pipeline and choose the type of build that matches your project type.
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 your options in Add build policy .
1. Select the Build definition .
2. Choose the type of Trigger . Select Automatic (whenever the source branch is updated) or
Manual .
3. Select the Policy requirement . If you choose Required , builds must complete successfully to complete
pull requests. Choose Optional to provide a notification of the build failure but still allow pull requests to
complete.
4. Set a build expiration to make sure that updates to your protected branch don't break changes for open
pull requests.
Immediately when branch name is updated : This option sets the build policy status in a pull
request to failed when the protected branch is updated. Requeue a build to refresh the build status.
This setting ensures that the changes in pull requests build successfully even as the protected branch
changes. This option is best for teams that have important branches with a lower volume of changes.
Teams working in busy development branches may find it disruptive to wait for a build to complete
every time the protected branch is updated.
After n hours if branch name has been updated : This option expires the current policy status
when the protected branch updates if the passing build is older than the threshold entered. This
option is a compromise between always requiring a build when the protected branch updates and
never requiring one. This choice is excellent for reducing the number of builds when your protected
branch has frequent updates.
Never : Updates to the protected branch don't change the policy status. This value reduces the number
of builds for your branch. It can cause problems when closing pull requests that haven't updated
recently.
5. Enter an optional Display name for this build policy. This name identifies the policy on the Branch
policies page. If you don't specify a display name, the policy uses the build definition name.
6. Select Save .
When the owner pushes changes that build successfully, the policy status is updated. If you have an
Immediately when branch name is updated or After n hours if branch name has been updated build
policy chosen, the policy status updates when the protected branch is updated if the most recent build is no
longer valid.
Status checks
External services can use the PR Status API to post detailed status to your PRs. The branch policy for additional
services brings the ability for those third-party services to participate in the PR workflow and establish policy
requirements.
For instructions on configuring this policy, see Configure a branch policy for an external service.
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. You can also
specify an Activity feed message .
If you select Required , then the pull request can't 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.
The number of reviewers specified for 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.
You can select Allow requestors to approve their own changes .
You can select Requestors can approve their own changes .
When all required reviewers approve the code, you can complete the pull request.
IMPORTANT
Use caution when granting the ability to bypass policy, especially at the repo and project level. Policies are a cornerstone
of secure and compliant source code management.
Path filters
Several branch policies offer path filters. If a path filter is set, the policy will only apply when files which match
the filter are changed. Leaving this field blank means that the policy will always apply.
You can specify absolute paths and wildcards. Examples:
/WebApp/Models/Data.cs
/WebApp/*
*.cs
Paths prefixed with ! are excluded if they would otherwise be included. Example:
/WebApp/*;!/WebApp/Tests/* - includes all files in /WebApp except files in /WebApp/Tests
!/WebApp/Tests/* - specifies no files, since nothing is included first
The order of filters is significant. They're applied left-to-right.
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 wildcard characters can you use for 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 can't 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 you make a pull request into a branch with branch policies configured, it enables the Set auto-complete
button for the pull request. Use this option to automatically complete if you don't expect any problems with your
changes. Your pull request finished once it meets all policies.
Azure DevOps Ser vices | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 - TFS
2017
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.
IMPORTANT
To view the content available for your platform, make sure that you select the correct version of this article from the
version selector which is located above the table of contents. Feature support differs depending on whether you are
working from Azure DevOps Services or an on-premises version of Azure DevOps Server, renamed from Team Foundation
Server (TFS).
To learn which on-premises version you are using, see What platform/version am I using?
1. Open the Branches page by navigating to your project in the web portal and selecting 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.
Set permissions
Control branch permission settings from the branch permission view. Users and groups with permissions set at
the repo level will inherit those permissions by default. To learn more about how permissions work, see
Permission settings.
Permissions in TFS 2017 Update 1 through TFS 2018 Update 2
P ERM ISSIO N DESC RIP T IO N
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
The Exempt from policy enforcement , (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.
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.
The following permissions are automatically assigned to branch creators: Contribute, Edit Policies, Force Push,
Manage Permissions, and Remove Others' Locks.
Delete a Git branch from the web portal
3/18/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018
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.
NOTE
There is no retention policy on deleted branches. A deleted Git branch can be restored at any time, regardless of when it
was deleted.
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
3/6/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018
When you have many people collaborating in a repository, the number and names of branches can quickly get
out of control. Hierarchical branch folders is an effective way to tame the chaos. Azure DevOps Services, TFS,
and Visual Studio treat / as a folder separator and will automatically collapse folders by default. This way, you
don't have to wade through every single branch to find the one you're looking for. You don't have to rely on
everyone to get it right, either. Azure Repos and TFS can enforce the correct use of branch folders.
Planning
Decide on the folder structure you want to allow. As an example, we'll set our repository to enforce the following
rules:
Only main can exist at the repository root.
All users will be allowed to create branches under the feature/ and users/ folders.
Administrators will be able to create branches under the release/ 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 ).
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 .
NOTE
The command tf.exe is installed by default with Visual Studio. You can access it via the Developer Command Prompt.
For additional options, download Team Explorer.
Enforce permissions
Run the following commands in the Developer Command Prompt, under Star t > Visual Studio > 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 main (in case it ever gets accidentally deleted).
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 /? .
1. Open your repo on the web and select the Branches view.
2. Locate your existing branch. If you don't see it, you may need to look on the All tab.
3. Choose its context menu (the ... button) and choose New branch .
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
4/17/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 with locking if you want to ensure that changes in a
branch are reviewed before they are merged and prevent changes in the locked branch.
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 Ser ver 2020 | Azure DevOps Ser ver 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.
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
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
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
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.
Share code with push
3/18/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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. Git adds your commits 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. 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 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
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
1. In Team Explorer, select Home and then choose Sync to open Synchronization .
You can also go to Synchronization from the Changes view by choosing Sync immediately after
making a commit.
During 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
Go to Team Explorer > Settings > Repositor y Settings . Make sure that you've entered the correct User ,
Email, Remotes , and other settings.
Next steps
Review code with pull requests or update code with fetch and pull
Update code with fetch and pull
3/6/2021 • 7 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 doesn't 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's a merge conflict between a commit you haven't pushed yet and a commit you're merging or pulling,
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
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
Visual Studio uses the Sync view in Team Explorer to fetch changes. Changes downloaded by fetch aren't
applied until you Pull or Sync the changes.
1. In Team Explorer, select the Home button and choose Sync .
There are two Fetch links, one near the top and one in the Incoming Commits section. You can use
either one.
3. Review the results of the fetch operation in under Incoming Commits .
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 keeps the commit history of your local
changes. When you share your branch with push, Git knows 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
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
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. This operation
synchronizes the commits on the local and remote branch.
1. In Team Explorer, select the Home button and choose Sync .
2. In Synchronization , select Sync .
Visual Studio
Command Line
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
Open the Team Explorer and open the Sync view. Then click the Pull link under Incoming Commits to pull
remote changes and merge them into your local branch. Pulling updates files in your open project, so make sure
to commit your changes before pulling.
1. In Team Explorer, select the Home button and choose Sync .
2. In Synchronization , 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.
3. Review the confirmation message when the pull operation completes.
Update your branch with the latest changes from main
When working in a branch, you may want to incorporate the latest changes from the main branch into your
branch. There are two approaches you can use: rebase or merge.
Rebase takes the changes made in the commits in your current branch and replays them on the history of
another branch. Rebasing rewrites the commit history of your current branch. The history starts from the
most recent commit in the target branch of the rebase.
Merge merges the changes from the source branch to the target branch using a merge commit, which
becomes part of the commit history.
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
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
NOTE
The git pull origin main command combines git fetch and git merge commands. To do this properly in Visual
Studio integration, you will need to Sync in Team Explorer to do the fetch part. This ensures your local git repository
is up to date with its remote origin.
To merge the latest changes from the main branch to your branch:
1. In Team Explorer, select the Home button and choose Branches .
2. Check out your target branch. Right-click the target branch, and choose Merge From .
3. Specify a Merge from branch , which is main in this example, and then select Merge .
If there are any merge conflicts, Team Explorer tells you now. Resolve the merge commits before the next
step.
4. Enter a commit message and select Commit Staged .
5. When you're 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
Resolve merge conflicts
3/11/2021 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 in 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 main, Git can't determine which changes to use in the merged version.
You may want to keep the changes in the main branch, the bugfix branch, or some combination of the two.
Resolve this conflict with a merge commit on the main 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.
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
1. You'll be informed of the merge conflict(s) when you pull changes or attempt to merge two branches.
2. The conflict notification appears. Click the Conflicts link to start resolve file 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
Copy changes with cherry-pick
3/6/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
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 Histor y....
3. Right-click the commit you want to cherry-pick and select Cherr y-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
Undo changes
3/18/2021 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
Visual Studio
Command Line
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
Open up the Changes view in Team Explorer. Select Actions and choose View Histor y from the drop-down. In
the history window that appears, right-click the commit to undo and select Rever t from the context menu.
Reset a branch to a previous state
Use reset to bring a branch in your local repository back to the contents of a previous commit. The most
common use of the reset command is to simply discard all changed files since the last commit and return the
files to the state they were in at the most recent commit.
WARNING
Don't use reset on branches shared with others. Use revert instead.
Visual Studio
Command Line
Next steps
Ignore files
Apply changes with rebase
3/11/2021 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 main 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 main 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 main 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
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
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.
This will open up an editor where you will see something like:
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 main branch.
Next steps
Copy changes with cherry-pick
Working with Git tags
3/6/2021 • 10 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
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 Visual Studio Team Services 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 Visual Studio Team Services is now Azure DevOps Services.
Annotated tags are displayed with a tag name, message, commit, tagger, and creation date. Lightweight
tags are displayed with a tag name and commit.
2. To filter the list of tags, type a search term into the Search tag name box and press Enter .
Browser
Visual Studio
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.
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 .
To delete a tag, you must have the Force Push permission at the Repositor y level or the All tags level (which
inherits its permissions from the repository level if not explicitly set). Force push permissions for a branch are
also automatically inherited by the branch creator.
Browser
Visual Studio
3. The tag is deleted, and won't be displayed the next time you navigate to the Tags view.
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.
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.
1. To view the history for a tag, select the ellipsis to the right of the tag name and choose View histor y .
2. You are taken to the commits view for the tag.
1. To view the history for a tag, select the ellipsis to the right of the tag name and choose View histor y .
2. You are taken to the commits view for the tag.
Commit history
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 histor y , first parent , full
histor y , and full histor y 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 histor y .
When you click on Show rename histor y you can view all the commits of the file or folder before the rename.
Commit details
3/6/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 main 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 Cherr y-pick to cherry pick a commit and port the changes to another branch.
Revert - Click on Rever t 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
Create, view, and manage pull requests
3/20/2021 • 26 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 main 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.
4. You can view all of your pull requests across different projects in your organization by choosing Pull
requests in the My Work view.
Manage 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 Create a pull request 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, Azure Repos prompts you to create a pull request in the Code
view on the web. This prompt is displayed on Pull Requests and Files .
Select Create a pull request 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 Backlogs or Queries in the Work view, open the work item with the linked branch.
2. In the Development area of the work item, select Create a pull request .
The link takes you 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. You can enter your pull request details and create the pull request.
Pick the branch you want to have reviewed and the branch you want to merge the changes into, such as the
main branch.
From Visual Studio
NOTE
Visual Studio 2019 now includes a new Git tool that provides an improved experience when connecting to a Git
repository. When you enable this tool, the Team Explorer tool is effectively disabled when connected to a Git repository.
You can acquire the new tool by downloading Visual Studio 2019 version 16.6. To enable and use the new tool, see Git
experience in Visual Studio (Preview).
4. 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.
In Pull Requests , you can also view pull requests opened by you or assigned to you.
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.
Sometimes you might want to create a pull request but you aren't ready to send it to the entire team for review.
A draft pull request indicates that a pull request is a work in progress. You don't have to resort to title prefixes
such as WIP or DO NOT MERGE. When the pull request is ready for review, you can publish it, and begin or
resume the full review process.
Draft pull request differences
Create a draft pull request
Publish a draft pull request
Mark as draft
Draft pull request differences
Draft pull requests have the following differences from published pull requests:
Build validation policies are enabled but not run automatically. They can be manually queued by selecting
the ... menu beside the build in the pull request.
Voting is disabled while in draft mode.
Required reviewers aren't automatically added.
Notifications are sent while in draft mode, but only to reviewers that you explicitly add to the draft pull
request.
Draft pull requests are displayed in the pull requests list with a special badge.
When you publish a pull request, required reviewers are assigned and notified, policies are evaluated, and
voting begins.
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.
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 your
changes solve. Change the pull request title, add a detailed description, add reviewers, add attachments, 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. You can also add or update all of these items
after you create the pull request.
Help reviewers using pull request tags
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. You can append some extra text in
the title, perhaps a "[WIP]" prefix or "DO NOT MERGE". Tags provide a way to give pull requests extra
information. Use tags to communicate important details and help organize pull requests.
To add a tag when creating a pull request, type a tag name in the Tags section. After you create a pull request,
you can manage its tags in the Tags section.
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. You can 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. Use tags to communicate important details and help organize pull requests.
To add a label when creating a pull request, choose Add label . After you create a pull request, you can manage
its labels in the Labels section.
Add and remove reviewers
Add reviewers to your pull request:
1. Select Over view in the pull request.
2. Select the Add button in the Reviewers area, and then select Required or Optional .
3. Enter the name of the user or group to add to the reviewer list for the pull request. If the user isn't a
member of your project, you'll need to add them.
4. As you enter a name or email address, a list of matching users or groups appears. Select the user or
group from the list to add them as a reviewer.
Edit the pull request description by selecting the edit icon in the description section.
Keep these fields up to date so that reviewers know what the changes in the pull request are trying to
accomplish.
Starting with Visual Studio 2017 Update 6, you can check out the source branch from a pull request directly
from Pull Requests in Team Explorer . Right-click the pull request and choose Checkout Source Branch .
Filter pull requests
Filtering allows you to find and organize your pull requests, enabling you to prioritize the most important files
in your workflow.
Create custom queries
You can create multiple custom queries on the pull request page with additional filters, such as draft state. These
queries create separate and collapsible sections to enable better pull request actionability. The queries work
across repositories on the My pull requests tab of the organization home page.
Filter by comments
Use comment-related filters on the pull request details page for faster reviews:
Comment status: Active (default), All , Pending , Resolved , As designed , Won't fix , and Closed .
Commented by: Filter for comments left by a specific person.
File types: Show all files (default), and Show only the files that have been commented on .
Filter by target branch
On the Pull requests page, click the Filter icon, and then select Target branch . Select the branch you want
from the drop-down.
Browse code changes
Select Files to view the changes made to the source branch next to the target branch of the pull request.
NOTE
When viewing the difference for a single selected file, there is a size limit of 5 MB for the file. To view and diff files larger
than 5 MB, you can download the file and view it using a local diff tool. When viewing the difference for a collection of files
in the Files view, the size limit for each file is 0.5 MB for performance reasons.
Review previous versions of the code from the All changes drop-down list.
Review previous versions of the code from the All updates drop-down list.
Every time Azure Repos updates the branch, it adds a new version to the list and on the Updates tab.
The diff view updates as you select different changes. It shows the differences between the files in the selected
and previous version in the pull request.
View code coverage metrics for changes within the pull request view. This ensures that you have adequately
tested your changes through automated tests. Coverage status appears as a comment in the pull request
overview. You can view details of coverage information for every code line that is changed in the file diff view.
Catch up with a pull request after being away from it by stepping through changes made since your last review.
Browse a list of changes from the author using Updates .
You can select and view changes made in commits on the branch in Commits .
You can see a preview of how a markdown file will look by selecting the View button on the file, and then
selecting Preview from the drop-down.
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
button. Leave feedback not tied to a specific code change by commenting in Over view . 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. Select Resolve or Reply & resolve to update comments in the
conversation.
Additional options are available in the comment resolution drop-down list.
4. Select any of the following post-completion options (some options are not available depending on the
merge type):
Complete associated work items after merging to complete any linked work items.
Delete <branch name> after merging to delete the source branch from the pull request.
Customize merge commit message to add a custom merge commit message.
Override branch policies and enable merge to force a branch to merge even if it doesn't satisfy
all branch policies. This option is only available if you have Exempt from policy enforcement
permissions.
5. Select Complete merge .
Linked work items are also updated showing the pull request completion.
There are a few situations when rebasing during pull request completion is not possible:
If a policy on the target branch prohibits using rebase strategies, you will need “Override branch policies”
permission.
If the source branch of the pull request has policies, you won’t be able to rebase it. Rebasing will modify the
source branch without going through the policy approval process.
If you’ve used the Merge Conflict Extension to resolve merge conflicts. Conflict resolutions applied to a three-
way merge are seldom successful (or even valid) when rebasing all the commits in a pull request one at a
time.
In all these cases, you still have the option of rebasing your branch locally and pushing to the server, or squash-
merging your changes when completing the pull request.
1. Select Complete in the upper right of the pull request view to complete your pull request after the
reviewers approve of 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 it meets all branch policies.
Abandon : Close the pull request without merging the changes.
2. In Complete pull request , enter the message for the merge commit and update the pull request
description.
3. Select any of the following options:
Complete linked work items after merging to complete any linked work items.
Delete <branch name> after merging to delete the source branch from the pull request.
Squash changes when merging to squash merge your pull request.
Override branch policies and enable merge to force a branch to merge even if it doesn't satisfy
all branch policies. This option is only available if you have Exempt from policy enforcement
permissions.
NOTE
Existing policies are still enforced. For example, if your branch currently has a “squash merge only” policy in place,
you will have to edit that policy in order to use the new merge types.
There are a few situations when rebasing during pull request completion is not possible:
If a policy on the target branch prohibits using rebase strategies, you will need “Override branch policies”
permission.
If the source branch of the pull request has policies, you won’t be able to rebase it. Rebasing will modify the
source branch without going through the policy approval process.
If you’ve used the Merge Conflict Extension to resolve merge conflicts. Conflict resolutions applied to a three-
way merge are seldom successful (or even valid) when rebasing all the commits in a pull request one at a
time.
In all these cases, you still have the option of rebasing your branch locally and pushing to the server, or squash-
merging your changes when completing the pull request.
1. Select Complete in the upper right of the pull request view to complete your pull request after the
reviewers approve of 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 it meets all branch policies.
Abandon : Close the pull request without merging the changes.
2. In Complete pull request , enter the message for the merge commit and update the pull request
description.
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
Go to your project and select Project settings > Notifications to view your notification settings.
Select the Notifications tab to view your notification settings, and choose New subscription to
subscribe to additional notifications.
To edit a notification, select ... for the notification and choose View to edit the subscription.
To opt-out of a notification, set the State to Off .
NOTE
The branch created during this revert has a single commit that reverts the file changes in the pull request. The branch
doesn't 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. You can use a branch other than main for new changes or change your main line of development in
your repo. To change the default branch name for new repositories, see All repositories settings and policies.
1. Navigate to your repository and select Branches .
2. Select the desired new default branch. You need at least two branches in order to change the default. If
there's only one, it will already be the default branch. In that case, you must create a second one in order
to change the default.
3. Select the ... beside the desired branch and choose Set as default branch .
4. Once you've set the new default branch, you may delete the previous one if desired.
1. Select the settings button in your project open to open the project administration page.
5. Once you've set the new default branch, you may delete the previous one if desired.
There are other aspects you should consider before making this change. Learn about them in the topic on
changing your default branch.
Squash merge pull requests
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019
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.
When a pull request is created, you can append any of the available pull request templates by choosing them
from the Add a template drop-down. The names in the drop-down are based on the file names of the
templates.
In the following example three templates are listed.
dev.md - This is the branch specific template that was applied by default to this pull request into the dev
branch, as indicated by the default message listed after the filename.
additional.md - This is an additional template.
pull_request_template.md - This is normally the default template but it was overridden by the dev.md
branch specific template in this pull request. Even though it was not added by default, it can still be applied
by selecting it from the list.
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.
Customize and extend pull request workflows with
pull request status
11/2/2020 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 Update 2
Pull requests are a great tool for facilitating code reviews and managing code movement within a repository.
Branch policies enforce code quality during the pull request process by establishing requirements that must be
performed for every code change. These 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 and allow external services to programmatically sign off on a
code change by associating simple success/failure type information with a pull request. Optionally, pull requests
can be blocked until the external service approves the change.
Integrating into the PR workflow involves a few different concepts:
Pull request status - provides a way for services to associate success/failure information with a pull request.
Status policy - provides a mechanism to block pull request completion until the pull request status indicates
success.
Custom actions - provides a way to extend the status menu using Azure DevOps Services extensions.
In this topic, you'll learn about pull request statuses and how they can be used to integrate in the PR workflow.
This status would be displayed to the end user in the PR Details view:
The stateis 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 Restar t
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
Review history
3/18/2021 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 main 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.
Browser
Visual Studio
Command Line
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.
Browser
Visual Studio
Command Line
5. Select your target branch, type a topic branch name if necessary, and click Rever t .
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.
Browser
Visual Studio
Command Line
2. On the branch you want to compare, click the ellipses on the right-side, and then select Compare
branches from the drop-down.
3. Select the other branch you want to compare with. The view displays all changes between the branches.
Understand Git history
3/6/2021 • 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 main 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 main branch with the following command:
git pull origin main
This copies ("pulls") all commits from the main branch of the remote repo (called origin by default) to the
main branch of the local repo. The pull operation copied one new commit, and the main 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 main . 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 main -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 main:
commit 6b33d99b996c430a60c9552b79245d1aa8320339
Date: Mon Feb 15 10:45:33 2016 -0500
commit 206613ccd9a54b055b184c7b6c16f2ece8067e51
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
Date: Mon Feb 15 10:51:06 2016 -0500
commit 206613ccd9a54b055b184c7b6c16f2ece8067e51
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?
> git log --full-history test.txt
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
Date: Mon Feb 15 10:59:34 2016 -0500
commit fdd4dfd816c4efebc5bdb240f49e934e299db581
Date: Mon Feb 15 10:51:06 2016 -0500
commit 6b33d99b996c430a60c9552b79245d1aa8320339
Date: Mon Feb 15 10:45:33 2016 -0500
commit 206613ccd9a54b055b184c7b6c16f2ece8067e51
Date: Mon Feb 15 10:44:18 2016 -0500
Initial commit
Update : Since I wrote this article, Azure DevOps Services has introduced a number of awesome history viewing
options on the web. What this means is that if you don't want to go slogging through the command line, you
can simply pull up the file you wish to view history for in our explorer and you will be presented with the below
history filter where you can specify simple or non-simple history views:
(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.
Drive Git development from a work item
3/6/2021 • 6 minutes to read • Edit Online
Azure DevOps Ser vices | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
Review this article to learn:
How to create a new branch or pull request from a work item
Complete the pull request
Perform a squash merge
Create a branch for several work items
Link a work item to existing development and build objects
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 Azure DevOps Server 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 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.
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 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.
Workflow process
Consider creating a new branch when there are no linked code artifacts. If there is a branch but no pull requests,
consider creating a pull request. Here's a typical workflow sequence when working with a Git repository.
1. Start work on the work item by creating a branch. You can add a new Git branch from within the
Development section...
NOTE
You can only create a branch once you've added files to the main branch, which we recommend you label main
or other distinctive label. 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 main 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.
To link a work item to an existing object, choose the Add links icon and then choose the link type.
Or, you can select it from the Links tab and choose Actions for the link and then choose the Remove
link option.
Related articles
Learn more about tracking work with work items and developing with Git from these resources:
Link to work items from other objects
Add work items
Git overview
Link GitHub commits and pull requests to work items
Create your backlog
Add work items
Git overview
Link GitHub commits and pull requests to work items
Create your backlog
Add work items
Git 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 don't display several of
the features that are available from the web portal.
Associated work items in build
With Git commits, any work items that have been linked to a commit are 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.
Resolve work items on commit
11/2/2020 • 2 minutes to read • Edit Online
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.
NOTE
In Microsoft Team Foundation Server (TFS) 2018 and previous versions, build and release pipelines are called definitions,
runs are called builds, service connections are called service endpoints, stages are called environments, and jobs are called
phases.
Use triggers to run a pipeline automatically. Azure Pipelines supports many types of triggers. Based on your
pipeline's type, select the appropriate trigger from the list below:
T RIGGER T Y P E P IP EL IN E YA M L VERSIO N
CI triggers ( trigger ) The version of the pipeline in the pushed branch is used.
PR triggers ( pr ) The version of the pipeline in the source branch for the pull
request is used.
GitHub pull request comment triggers The version of the pipeline in the source branch for the pull
request is used.
T RIGGER T Y P E P IP EL IN E YA M L VERSIO N
Pipeline completion triggers See Branch considerations for pipeline completion triggers.
Azure Pipelines | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 | TFS 2017
NOTE
In Microsoft Team Foundation Server (TFS) 2018 and previous versions, build and release pipelines are called definitions,
runs are called builds, 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.
Unless you specify a trigger in your YAML file, a change in any of the branches will trigger a build. Add the
following snippet to your YAML file in the main branch. This will cause any changes to main and feature/*
branches to be automatically built.
trigger:
- main
- feature/*
Exclude or include tasks for builds based on the branch being built
The main 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 main 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 main 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/main'))
Unless you specify pr triggers in your YAML file, pull request builds are automatically enabled for all branches.
You can specify the target branches for your pull request builds. For example, to run the build only for pull
requests that target: main and feature/* :
pr:
- main
- feature/*
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
Create a pull request status server with Node.js
11/2/2020 • 8 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018
The pull request (PR) workflow provides developers with an opportunity to get feedback on their code from
peers as well as from automated tools. 3rd party tools and services can participate in the PR workflow by using
the PR Status API. This article guides you through the process of creating a status server to validate PRs in an
Azure DevOps Services Git repository. For more information about PR status, see Customize and extend pull
request workflows with pull request status.
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.
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 Ser vice 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": "https://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
11/2/2020 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018
The pull request (PR) workflow provides developers with an opportunity to get feedback on their code from
peers as well as from automated tools. 3rd party tools and services can participate in the PR workflow by using
the PR Status API. This article guides you through the process of creating a custom branch policy using Azure
Functions to validate PRs in an Azure DevOps Services Git repository. With Azure Functions you don't have to
worry about provisioning and maintaining servers, especially when your workload grows. Azure Functions
provide a fully managed compute platform with high reliability and security.
For more information about PR status, see Customize and extend pull request workflows with pull request
status.
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 Ser vice 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;
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 = "https://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
3/11/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 Update 2
Branch policies are a powerful feature to ensure high quality code in your repo by establishing requirements for
all pull requests. External services can use the PR Status API to post detailed status to your PRs. The branch
policy for external services brings the ability for those 3rd party services to participate in the PR workflow and
establish policy requirements. This article guides you through the process of configuring a branch policy for a
service that is posting PR status. For more information about PR status, see Customize and extend pull request
workflows with pull request status.
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.
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.
Git command reference
4/17/2021 • 9 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 | TFS 2017 | TFS
2015 | VS 2017 | VS 2015 Update 2
Visual Studio's Team Explorer lets you do most common Git tasks that you'll need for your daily work. From the
Visual Studio View menu, open Team Explorer or use the Ctrl+, Ctrl+M hotkey.
Team Explorer and the Git command-line work great together. When you make updates and run 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, installGit for Windows to set up the Git Credential Manager Core. 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
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
Select the Connect button ( ) in Team Explorer to open the Connect view, then select New under Local Git
repositories
Create the repo from the command line, then open Team Explorer's Connect view and select Add under Local
Git repositories
Open the solution and select Publish ( ) from the status bar in the lower right.
Delete the Git repo and history, but keep the current version of the files
Delete the hidden .git folder created at the root of the repo
Delete the hidden .git folder created at the root of the repo from Windows Explorer or the command line
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 Repositor y 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 Repositor y Settings , and select Edit under Remotes
Branches
How do I?
Git command-line
Visual Studio
Commits
How do I?
Git command-line
Visual Studio
Open the Changes view in Team Explorer. Select the + icon in the Changes list to stage all changes for the next
commit.
Open the Changes view in Team Explorer. Unstaged changes are listed under Changes section.
Delete a file
git rm filename
git commit -m "filename"
Delete the file through Solution Explorer, the command line, or any other means. Right-click the deleted file in
Team Explorer's Changes view and select Stage . Select Commit Staged to commit the deletion.
Move a file
git mv filename
git commit -m "Moved filename"
Move a file from one location to another in your repo through Solution Explorer, the command line, or any other
means. Right-click the moved file in Team Explorer's Changes view and select Stage . Select Commit Staged
to commit the move.
Tag a commit
git tag -a tagname -m "description"
Open the Changes view in Team Explorer, then choose View histor y..." from the Action drop-down. Locate
the commit in the History view, then right-click and select Create Tag
Compare the current contents of a single file and the contents in the last commit
git diff HEAD filename
Right-click the change in the Changes view in Team Explorer and select Compare with unmodified .
Compare your current version with a branch
git diff branchname
Right-click a file in Solution Explorer and select View Histor y..., then select both on the latest commit on your
current branch and the latest commit on the remote branch. Right-click and select Compare
Sync changes
How do I?
Git command-line
Visual Studio
Download new branches and commits from a remote repo, but do not merge them into your local branches
git fetch
Open the Sync view from Team Explorer and select Fetch .
Synchronize your local branch with a remote branch, pushing your local changes and pulling remote ones
git pull remote branchname
git push -u remote branchname
Open the Sync view in Team Explorer. Select Sync .
Force push a branch, rewriting the remote branch history with the history of your current branch
git push --force -u origin remote_branchname
Use command line
Not applicable
Undo
WARNING
If you are not an experienced Git user, exercise caution when using the reset command. Learn more
How do I?
Git command-line
Visual Studio
Revert all changes and roll back to the most recent commit
git reset --hard HEAD
Open the Changes view in Team Explorer. Select **Actions and choose View Histor y from the drop-down.
Right-click the commit where the branch is currently located and select Reset and Delete changes....
Open the Changes view in Team Explorer. Select **Actions and choose View Histor y from the drop-down.
Right-click the commit where the branch is currently located and select Reset and Keep changes....
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 recent commit on a remote branch
git reset --hard remote/branchname
(for example, git reset --hard origin/master )
Right-click the branch from Team Explorer's Branches view and select Reset and Delete changes....
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
PA RA M ET ER DESC RIP T IO N
/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.
PA RA M ET ER DESC RIP T IO N
/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.
/teamproject: TeamProjectIdentifier Specifies the name of the project that contains the
permissions to view or modify.
/repositor y: RepositoryIdentifier Specifies the name of the repo that contains the permissions
to view or modify.
/branch: BranchName Specifies the name of the branch that contains the
permissions to view or modify. If you specify /branch , you
must also specify /repositor y .
/login: username,[password] Specifies the user account to run the command. See Use
Team Foundation version control commands.
See Git repository permission namespaces 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.
In this example we'll use the following collection, project, and repository:
/collection:https://fabrikam-fiber.visualstudio.com
/teamproject:FabrikamProject
/repositor y:FabrikamRepo
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).
tf git permission /allow:CreateBranch
/group:"[FabrikamProject]\Project Administrators"
/collection:https://dev.azure.com/fabrikam-fiber/
/teamproject:FabrikamProject
/repository:FabrikamRepo
/branch:master
Git view command
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
PA RA M ET ER DESC RIP T IO N
/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.
/repositor y: 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 .
PA RA M ET ER DESC RIP T IO N
/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
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>/<project>/_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>/<project>/_git/<repo>/subfolder1
go get dev.azure.com/<organization>/<project>/_git/<repo>/subfolder1/subfolder2
IMPORTANT
To access private Azure Repos Git repositories using go get, you must first set the environment variable
GOPRIVATE=dev.azure.com . You can set this environment variable locally before building or running.
SSH
To use SSH with go get , you must have SSH keys set up for Azure DevOps as described in Use SSH Key
authentication.
When you have SSH keys set up, add this entry to your .gitconfig file:
[url "git@ssh.dev.azure.com:v3/<organization>/"]
insteadOf = https://dev.azure.com/<organization>/
With this entry and a specific URL format, you can now use go get .
NOTE
The .git that follows the repo name and _git are not included because you're using the SSH URL.
go get dev.azure.com/<organization>/<project>/<repo>.git
HTTPS
To use HTTPS with go get , you must create a PAT as described in Authenticate access with personal access
tokens. This PAT requires only the Code (read) scope.
After you create the PAT, add this entry to your .gitconfig file:
[url "https://<user>:<token>@dev.azure.com/<organization>/<project>/_git/<repo>"]
insteadOf = https://dev.azure.com/<organization>/<project>/_git/<repo>
The <user> part can be any non-empty string; we suggest the word pat .
With this entry and a specific URL format, you can now use go get .
NOTE
Be sure to use .git after the repo name.
go get dev.azure.com/<organization>/<project>/_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>/<project>/_git/<repo>.git/subfolder1
go get dev.azure.com/<organization>/<project>/_git/<repo>.git/subfolder1/subfolder2
Default Git repository and branch permissions
4/17/2021 • 2 minutes to read • Edit Online
Azure DevOps Ser vices | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 - 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 default permissions for contributing to a branch or
repository.
Permission
Readers
Contributors
Build Admins
Project Admins
Read (clone, fetch, and explore the contents of a repository); also, can create, comment on, vote, and
Contribute to pull requests
️
✔
️
✔
️
✔
️
✔
Edit policies , Force push (rewrite histor y, delete branches and tags) , Manage permissions , Remove
others' locks
️
✔
Bypass policies when completing pull requests (not set for any security group)
Branch Creation : At the repository level, can push their changes to branches in the repository. Does not
override restrictions in place from branch policies. At the branch level, can push their changes to the branch and
lock the branch.
️
✔
️
✔
️
✔
Contribute : At the repository level, can push their changes to branches in the repository. Does not override
restrictions in place from branch policies. At the branch level, can push their changes to the branch and lock the
branch.
️
✔
️
✔
️
✔
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.
️
✔
️
✔
️
✔
Administer : Delete and rename repositories: If assigned to the top-level Git repositories entry, can add
additional repositories. At the branch level, users can set permissions for the branch and unlock the branch. The
Administer permission set on an individual Git repository does not grant the ability to rename or delete the
repository. These tasks require Administer permissions at the Git repositories top-level.
️
✔
Rewrite and destroy histor y (force push) : Can force an update to a branch and delete a branch. A force
update can overwrite commits added from any user. Users with this permission can modify the commit history
of a branch.
️
✔
By default, the Project Collection Build Service can read from all repositories. Any pipeline which runs within the
project collection scope can potentially read any repository in the organization or collection. To remove this
permission for a repository, change the Read permission to Deny for the Project Collection Build Service.
To change permissions or set policies for Git repositories or branches, see the following articles:
Git repository settings and policies
Set Git repository permissions.
Set permissions for a specific branch and set branch policies.
TIP
To quickly find a permission or setting defined for a project or organization, use the Organization search setting feature.
Related articles
Default permissions and access
Permissions and groups reference
Frequently Asked Git Questions
3/6/2021 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 main, doesn't that make the commit
history of main hard to follow over time?
Large projects with many commits and a range of contributors can result in commit histories for the main
branch that represent the development history of the topic branches merged into main 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 main 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:
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 Repositor y Settings link.
Git limits
3/6/2021 • 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, VFS for Git, 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.
Push size for LFS objects
Git LFS doesn't count towards the 5GB repo limit. The 5GB limit is only for files in the actual repo, not blobs
stored as part of LFS. If you get failing pushes on the 5GB limit verify your .gitattributes file includes the
extensions of the files you mean to track using LFS and that this file was saved and staged before you staged the
large files to be tracked.
Learn to map your familiar Team Foundation
Version Control (TFVC) commands and workflows to
Git
3/6/2021 • 10 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.
Create a workspace and get latest
When connecting to a TFVC repo for the first time, you typically create a workspace and get the latest code. so,
how do you get started in Git?
Similar to a workspace in TFVC you clone the Git repository to a folder on your machine. Cloning will
download all of the contents and history of the repository, to your local machine. Once you have the cloned
repo, nearly all operations are performed locally. You are able to work offline with a full backup of the
centralized repository.
Command Line
Visual Studio
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
Command Line
Visual Studio
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
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 > Histor y or CODE > Explorer > Histor y
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
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.
RPC failures and http.postBuffer
3/6/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 Ser ver 2020 | Azure DevOps Ser ver 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
Related articles
What is version control?
Migrate from TFVC to Git
Develop and share your code in TFVC using Visual
Studio
4/16/2021 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
NOTE
TFVC is not supported when workspaces are placed on network drives or UNC paths.
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.
My code is somewhere else. Can I migrate it to my TFVC project on Azure DevOps Services?
Yes:
Upgrade From Visual SourceSafe.
Migrate from Team Foundation Server into Azure DevOps Services.
I don't see the Configure Workspace link shown in the steps above. What do I do next?
You might already have a workspace on your computer. To see your workspace, open Source Control Explorer.
Or change your workspace. Find out how to manage files under source control or manage workspaces.
Next steps
Get your code reviewed
Share your code in TFVC using Eclipse
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
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
11/2/2020 • 10 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
1. In Team Explorer , on the My Work page, go to the Code Reviews & Request section and double-
click the request.
You can also open the shortcut menu for the request and choose Open .
2. Read the comments and reply to them as needed. To reply to a comment, choose Reply , enter your
comment in the box that appears, and then choose OK . To send your comments, choose Send
Comments .
3. To view a file and see the code-blocks that have comments, or to edit a file, go to the Comments section.
In the Files sub-section, open the shortcut menu for the file and choose either Compare (Read-Only)
or Edit File .
4. When you and the other reviewers finish responding to each other's comments and you are ready to
close the review, click Close Review , and then choose either:
Complete to indicate that the review is finished.
-or-
Abandon to indicate you are canceling the review.
Fix the test and the code
Having read Julia's comments, Peter fixes his unit test as she suggests. The test now fails. This shows that the
code is not yet correct.
Peter fixes the code:
/// <summary>
/// Returns true if two numbers are equal.
/// </summary>
public static bool EqualTo(double a, double b)
{
// Allow for rounding errors.
const double allowedErrorMultiple = 1/1000000;
double allowedError = (System.Math.Abs(a) + System.Math.Abs(b)) * allowedErrorMultiple/2;
return System.Math.Abs(a - b) < allowedError;
}
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 Ser ver 2020 | Azure DevOps Ser ver 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
Select an effective branching strategy
3/6/2021 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 - TFS 2015
Creating branches for your Team Foundation Version Control (TFVC) repositories are useful to isolate risk.
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.
This article explores 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.
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.
Choose a branching strategies with a DevOps
mindset
3/6/2021 • 4 minutes to read • Edit Online
Are you planning to embrace DevOps using the Team Foundation Version Control (TFVC) with Azure DevOps
Services or Azure DevOps Server? 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.
B RA N C H B UIL D EN VIRO N M EN T S N OT ES
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.
B RA N C H B UIL D P IP EL IN ES N OT ES
V1.00 RC_Bld Dev -> QA -> UAT -> Triggered with every
Staging -> Prod checkin 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.
B RA N C H B UIL D P IP EL IN ES N OT ES
V2.00 RC_Bld Dev -> QA -> UAT -> Triggered with every
Staging -> Prod checkin 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.
Branch folders and files
11/2/2020 • 7 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
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 Proper ties , 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 click Check In
Pending Changes .
3. Right-click the folder that you want to convert, point to Branching and Merging , and then click
Conver t to Branch .
The Conver t 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 Conver t .
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 Conver t to
Folder .
3. When the Conver t 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
Branch strategically
11/2/2020 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
When should the team add a branch?
You should create branches in the following situations:
When you must release code on a different schedule/cycle than the existing branches.
When your code requires a different branch policy. If you create a new branch that has the new policy,
you can add strategic value to your project.
When functionality is released to a customer and your team plans to make changes that do not affect the
planned release cycle.
You should not create a branching for each user story because it creates a high integration cost. Although TFVC
makes branching easy, the overhead of managing branches can become significant if you have many 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.
Explore the feature isolation strategy
3/6/2021 • 4 minutes to read • Edit Online
Azure DevOps Ser vices | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 - TFS
2015
Are you planning to implement Team Foundation Version Control's feature isolation strategy in Azure DevOps?
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 shor t-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 shor t-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.
Merge folders and files
3/6/2021 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
IM P O RTA N T
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.
Related articles
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
11/2/2020 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
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 Histor y .
3. In the Histor y 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 Ser ver 2020 | Azure DevOps Ser ver 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.
IM P O RTA N T
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 Proper ties to display the Proper ties 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
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
Ser ver , and then choose Configure User Tools .
--or--
c. In Windows, choose Star t , 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 Ser ver 2020 | Azure DevOps Ser ver 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 star t
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
3/6/2021 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
3/6/2021 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
11/2/2020 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 Ser ver .
IMPORTANT
Using a local workspace can have performance degrade as the number of items approaches or exceeds 100,000. This is
because local workspaces keep multiple copies of the same file to enable some version control actions locally due to the
DevOps Server connection not being reliably available. This also means there is more room taken up on disk.
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.
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
3/6/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
Related articles
Configure Command
Set and Enforce Quality Gates
Walkthrough: Customizing Checkin Policies and Notes
Test Impact for partially mapped TFVC repositories
in TFS/Azure DevOps Services
3/6/2021 • 2 minutes to read • Edit Online
Azure DevOps Ser vices | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 | TFS
2017 Update 1
Test Impact Analysis (TIA) has been part of VSTest task starting with version 2. This feature helps speed up the
DevOps cycle by helping you run only relevant tests for a build. Effectively, you end up running tests which are
affected by incoming changes and not the entire test suite. For more information about Test Impact Analysis, see
Accelerated Continuous Testing with Test Impact Analysis - Part 1.
In addition to supporting GitHub and Git in TFS/Azure DevOps Services, TIA also supports TFVC. This article
describes a known limitation about TIA in build/release pipelines based on TFVC and a work around to get past
this limitation.
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.
Develop code and manage pending changes
11/2/2020 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
NOTE
Empty folders will not appear.
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.
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
11/2/2020 • 9 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 director y 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
11/2/2020 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 Over write 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 Proper ties .
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
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
Impor tant:
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
11/2/2020 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
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
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
Work from the command prompt
Rename Command (Team Foundation Version Control) : Rename or move a file.
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)
11/2/2020 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 Over write 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 Ser ver 2020 | Azure DevOps Ser ver 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 keeping the changes in your
workspace
The gated check-in process provides a way to proceed with the check-in and continue working with your
changes. The drawback of proceeding in this way is that if the build completes successfully you must reconcile
the changes in your workspace with the changes that are checked into version control.
To proceed with the gated check-in after keeping your 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 Build Changes .
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.
3. After the build is completed:
Check-in committed : We recommend that you reconcile your workspace before you continue
developing your code. If you are using the Build Notifications application, the Gated Check-in
dialog box appears. Choose Reconcile . Otherwise, in Team Explorer , on the Builds page, under
My Builds , open the shortcut menu for the completed build, and then choose Reconcile
Workspace . When the Reconcile Workspace dialog box appears, use this dialog box to resolve
version control conflicts.
Check-in rejected : Correct the problems that caused the check-in to be rejected. 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 and contains
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.
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 Preser ve 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
Compare files
3/6/2021 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 - TFS 2015 | VS
2019 - 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.
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.
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 .
TIP
You can also press Shift and then double-click the file.
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.
Related articles
Compare folders
Compare folders
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
N A M E M A SK DESC RIP T IO N
*.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
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
11/2/2020 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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:
Histor y 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 Histor y and then select either Source Histor y or
Target Histor y .
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.
NOTE
If AutoMerge is disabled, then this conflict must be manually resolved.
IF Y O U WA N T T H E SY ST EM TO
A UTO M AT IC A L LY RESO LVE
C O N F L IC T S T H AT O C C URRED
B EC A USE. . . A S EXP L A IN ED IN T H IS EXA M P L E. . . T H EN SEL EC T T H IS C H EC K B O X. . .
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
are unique to the workspace workspace or target version: changes made only in the
(during get or checkin operation) local workspace or target
or target version (during merge or branch
rollback operation)
Content changes were made that four and five were added to the Conflicts with content
are unique to the server (during server or source version: changes made only in the
get or checkin operation) or ser ver version or source
source version (during merge or branch
rollback operation)
IF Y O U WA N T T H E SY ST EM TO
A UTO M AT IC A L LY RESO LVE
C O N F L IC T S T H AT O C C URRED
B EC A USE. . . A S EXP L A IN ED IN T H IS EXA M P L E. . . T H EN SEL EC T T H IS C H EC K B O X. . .
A file on the server (during get or You checked out a file that is Conflicts caused by renaming
checkin operation) or in the source named launch.cs and worked on file in the ser ver version or
branch (during merge or rollback it. During that time, someone else source branch
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
star t.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 ser ver 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 Preser ve 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.
T IP
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 Ser ver . 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
11/2/2020 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
Unlocking an Item
You can unlock an item explicitly by using the unlock command or implicitly when you check in. When you check
in pending changes to a locked item, Team Foundation removes any locks.
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
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
Get the history of an item
3/6/2021 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 Histor y 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 Histor y 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 Histor y .
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 Histor y 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:
TA SK SUP P O RT IN G C O N T EN T
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.
TA SK SUP P O RT IN G C O N T EN T
Get a past version of the item: Right-click a Download (get) files from the Server
changeset and then click Get This Version to
download the past version of the item to your
workspace.
View which users made specific changes within a View file changes using annotate
file: 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 Roll back changesets
single 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 .
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
TA SK SUP P O RT IN G C O N T EN T
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 Download (get) files from the Server
and then click **Get This Version to download the past
version of the item to your workspace.
View other branches to which the labeled changeset View where and when changesets have been merged
has merged: **Right-click the label and click **Track
Changeset . (This command is available only if the item is a
file.)
TA SK SUP P O RT IN G C O N T EN T
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
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 Histor y to open the Histor y 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 (<ser ver
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
3/6/2021 • 10 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
TIP
When you use this command to apply a label, you can specify a scope other than the project.
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
3/6/2021 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
11/2/2020 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
Histor y , 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 Preser ve shelveset on ser ver 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.
Default TFVC permissions
4/17/2021 • 2 minutes to read • Edit Online
Azure DevOps Ser vices | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 - TFS
2013
All members of the Contributors group with Basic access can contribute to a TFVC repository. The most
common built-in groups include Readers, Contributors, and Project Administrators. These groups are assigned
the default permissions for contributing to the repository as listed below.
NOTE
Tasks such as create, delete, or rename a TFVC repository are not supported. Once a TFVC repository is created you can't
delete it. Also, you can only have one TFVC repository per project. This is different from Git repositories which allow for
adding, renaming, and deleting multiple repositories.
Permission
Readers
Contributors
Build Admins
Project Admins
Check in , Label , Lock , Merge , Pend a change in a ser ver workspace , Read
Read only
️
✔
️
✔
️
✔
Administer labels , Manage branches , Manage permissions , Revise other users' changes , Undo other
users' changes , Unlock other users' changes
️
✔
To change permissions for TFVC repositories or branches, see Set TFVC repository permissions.
TIP
To quickly find a permission or setting defined for a project or organization, use the Organization search setting feature.
Related articles
Default permissions and access
Permissions and groups reference
Set TFVC repository permissions
4/17/2021 • 4 minutes to read • Edit Online
Azure DevOps Ser vices | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 - TFS
2013
You grant or restrict access to a TFVC repository to lock down who can contribute to your source code. There is
only one TFVC repository per project.
For guidance on who to provide greater permission levels, see Grant or restrict access using permissions.
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 the TFVC repository.
To contribute to the source code, you must be granted Basic access level or greater. Users granted Stakeholder
access for private projects have no access to source code. Users granted Stakeholder access for public projects
have the same access as Contributors and those granted Basic access. To learn more, see About access levels.
To contribute to the source code, you must be granted Basic access level or greater. Users granted Stakeholder
access have no access to source code. To learn more, see About access levels.
NOTE
Tasks such as create, delete, or rename a TFVC repository are not supported. Once a TFVC repository is created you can't
delete it. Also, you can only have one TFVC repository per project. This is different from Git repositories which allow for
adding, renaming, and deleting multiple repositories.
Permission
Readers
Contributors
Build Admins
Project Admins
Check in , Label , Lock , Merge , Pend a change in a ser ver workspace , Read
Read only
️
✔
️
✔
️
✔
Administer labels , Manage branches , Manage permissions , Revise other users' changes , Undo other
users' changes , Unlock other users' changes
️
✔
3. Next, choose the user or security group you want to change permissions.
To set permissions for a specific user or group, enter their name in the identity box and select their
identity.
Then make the changes to the permission set.
4. When done, navigate away from the page. The permission changes are automatically saved for the
selected group.
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.
NOTE
You may not be able to find a user from a permissions page or identity field if the user hasn't been added to the
project—either by adding it to a security group or to a project team. Also, when a user is added to Azure Active
Directory or Active Directory, there can be a delay between the time they are added to the project and when they
are searchable from an identity field. The delay can be between 5 minutes to 7 days.
1. To set the set the permissions for the TFVC repository for a project, choose TFVC Repositor y and then
choose the security group whose permissions you want to manage.
For example, here we choose (1) Project Settings , (2) Repositories , (3) the TFVC repositor y , (4) the
Contributors group, and then (5) the permission for Manage branch .
To see the full image, click the image to expand. Choose the close icon to close.
NOTE
You may not be able to find a user from a permissions page or identity field if the user hasn't been added to the
project—either by adding it to a security group or to a project team. Also, when a user is added to Azure Active
Directory or Active Directory, there can be a delay between the time they are added to the project and when they
are searchable from an identity field. The delay can be between 5 minutes to 7 days.
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.
2. Save your changes.
1. From the web portal, open the admin context by choosing the Settings and choose Version Control .
2. Choose the TFVC repository for the project and then choose the security group whose permissions you
want to manage.
3. Change the permission setting to Allow or Deny .
For example, here we change the Manage branch permission to Allow for all members of the
Contributors group.
NOTE
You may not be able to find a user from a permissions page or identity field if the user hasn't been added to the
project—either by adding it to a security group or to a project team. Also, when a user is added to Azure Active
Directory or Active Directory, there can be a delay between the time they are added to the project and when they
are searchable from an identity field. The delay can be between 5 minutes to 7 days.
Related articles
Grant or restrict access using permissions
Default permissions and access
Permissions and groups reference
Tf Team Foundation Version Control (TFVC) permission command-line tool
Security REST API commands
Configure Check-Out Settings
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 | TFS 2017 | TFS
2015 | VS 2017 | VS 2015 | VS 2013
Administrators of Team Foundation version control can configure source control check-out settings. Check-out
settings in Team Foundation version control enable files to be edited by more than one person at the same time.
The following procedure shows you how to configure check-out settings.
Required Permissions
To configure check-out settings, you must have the Edit project-level information set to Allow . For more
information, see Permissions and groups reference.
Procedure
To configure checkout settings
1. In Team Explorer , select the project for which you want to configure check-out settings.
2. From the Team menu, click Team Project Settings , and then click Source Control .
3. In the Source Control Settings dialog box, select the Check-out Settings tab.
4. Select or clear the Enable multiple checkout box.
5. Select or clear the Enable get latest on check-out box.
6. Click OK .
See Also
Tasks
Enable Team Foundation Version Control to Get the Latest Files on Check-Out
Set and Enforce Quality Gates
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 | TFS 2017 | TFS
2015 | VS 2017 | VS 2015 | VS 2013
Check-in policies are a mechanism for enforcing development practices across your development team. Check-
in notes are a communication mechanism for collecting data from team members during the check-in process.
Both of these are customizable to meet the needs of a team. This section explains the purpose of these items and
also describes how to configure them.
Check-in Policies
Check-in policies are used to enforce mandatory software development practices. Policy is enforced during the
check-in process in the Check In and Pending Changes windows. If a user attempts to perform a check-in, in
violation of a policy, their check-in is blocked. If necessary, these policies may be overridden. For more
information, see Override a Check-In Policy.
Policies are configured and established in the Source Control Settings window. A sample policy constraint is
"You must associate your changes with one or more work items." This policy prevents users from submitting
changes without having a specific bug or feature they are working on.
When policies are violated, they are presented to the user during the source control check-in process in the
Check In and Pending Changes window. For more information, see Using the Check In and Pending Changes
Windows.
Check-in Notes
Check-in notes are used for capturing specific pieces of information during the check-in process by prompting
the user for specific data. Check-in notes can be configured and made mandatory in the Source Control Settings
window. The information archived in check-in notes can be vital when viewing the details of a Working with
Changesets. For more information, see Viewing Historical Data about an Item.
Check-in notes are presented to the user during the source control check-in process in the Check In and Pending
Changes windows. For more information, see Using the Check In and Pending Changes Windows.
In This Section
Add Check-In Policies
Describes how to create custom check-in policies associated with Team Foundation version control check-ins.
Edit Check-In Policies
Explains the procedures used to modify a check-in policy.
Remove Check-In Policies
Describes the steps required to delete a check-in policy.
Enable and Disable Check-In Policies
Explains the steps used to either enable or disable an existing check-in policy.
Configure Check-In Notes
Describes the steps used to configure custom check-in notes associated with Team Foundation version control
check-ins.
See Also
Tasks
Check In Pending Changes
Other Resources
Viewing Historical Data about an Item
Control Access to Team Foundation Version Control
3/6/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 | TFS 2017 | TFS
2015 | VS 2017 | VS 2015 | VS 2013
Team Foundation version control supports granting access control permissions to Windows Groups, Windows
Users, and Team Foundation Groups. Permissions can be inherited from the containing folder, or you can declare
permissions explicitly.
Permission settings are in the form of either Grant or Deny . Deny always overrides Grant , even if Deny is
inherited and Grant is explicitly defined.
Required Permissions
To complete this task, you must have the Manipulate security settings permission set to Allow . For more
information, see Permissions and groups reference.
To set permissions for users or groups
1. On the Visual Studio View menu, click Other Windows , and then click Source Control Explorer .
2. Right-click the folder or file for which you want to set permissions, and then click Proper ties .
3. In the Proper ties dialog box, click the Security tab.
4. In the Add users and groups area, select Team Foundation Ser ver Group to set permissions for a
Team Foundation Server group. Otherwise, select Windows user or group .
5. Click Add .
a. If you selected Team Foundation Ser ver group, the Add Group dialog box opens. Select a
group, and then click OK . The group for which you want to set permissions appears in the User
and Groups box of the Proper ties dialog box.
b. If you selected Windows User or Group , the Select Users or Groups dialog box opens. Enter
the user or group for whom you want to set permissions, and then click OK . The user or group
appears in the User and Groups box of the Proper ties dialog box.
NOTE
To view a ToolTip that provides information about the controls in the Select Users or Groups dialog box, click
the Help icon on the title bar, and then click the control.
6. In the Users and Groups box of the Proper ties dialog box, select the user or group for which you want
to set permissions.
7. In the Permission box, select either Allow or Deny for each permission.
NOTE
If you select the Inherit security settings box, the security settings of the containing folder are selected
automatically. You can override these inherited settings by selecting or clearing the Deny box.
8. Click OK to close the Proper ties dialog box.
See Also
Other Resources
Administering Team Foundation Version Control
Remove Access to Version Control Files
11/2/2020 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 | TFS 2017 | TFS
2015 | VS 2017 | VS 2015 | VS 2013
As a Team Foundation administrator, you may have to remove access to a file that is under version control. For
example, someone may check in a file infected with a virus. You can also permanently destroy version controlled
files. For more information, see Destroy Version Controlled Files.
The following procedure provides the details for removing the file by using the user interface or the tf
command-line utility. Access is removed by overwriting the bad version with a clean version and adding the
clean version to the database. By setting the read/write permissions, you can prevent the file from appearing in
Source Control Explorer.
NOTE
Although the file remains in the database in a deleted state, do not remove the row for the file directly from the database
or you may experience unexpected results.
Caution:
If you remove the Read permission for the Ser vice Accounts security group on a file or folder that is
under version control, the VersionControl.Adapter might not be able to read the file or folder. If the adapter
cannot read the version control information in the data warehouse, the adapter will write a message in the
application-tier event log similar to The ser vice account might not have permissions to retrieve this
changeset . Without the version control information from the file or folder, the data warehouse, and
subsequent version control reports might not be completely accurate.
Required Permissions
To remove access to Team Foundation version control files, you must belong to the Team Foundation
Administrators group. For more information, see Permissions and groups reference.
To remove access to a file under version control
1. On the Visual Studio View menu, click Other Windows , and then click Source Control Explorer .
2. Locate and check out the file that you want to remove. For more information, see Check Out and Edit
Version-Controlled Items.
3. In the Check Out dialog box, verify that the correct file is selected, then click Check Out in the Select
lock type options.
4. Create a new file and save the file in the same location and with the same name and extension as the
latest version of the file that you want to overwrite.
5. Check in the file. For more information, see Check In Pending Changes.
NOTE
You might want to make sure that any client user who has a local copy of the file on their computer, removes any
reference to the file in Solution Explorer and manually removes any copy of the file on their client computer.
6. Right-click the file and then click Proper ties to open the Proper ties dialog box for the file. On the
Proper ties dialog box, click the Security tab, and clear the Inherit Security Settings box.
7. Click deny for each user and group except Administrators .
8. Click OK and the file is removed for other users from Source Control Explorer.
To remove access to the file from the command line
1. Open the command line and use the CheckOut command of the tf utility to obtain a write-enable
version of the file that you want to remove. For example:
tf checkout myfile.cs
2. Create a new file and overwrite the file that you want to remove.
3. Use the CheckIn command to replace the version of the file in the database.
For example, you might want to add a comment describing that you overwrote the file and that the
permissions are denied.
tf checkin /comment:"Over wrote bad file and denied permissions."
4. Use the permission command together with the /deny option to change the permissions to that file for
a user or a group.
For example, you can use the following command to deny read permissions on the file to groups on the
ADATUM domain.
tf permission /inherit:no myfile.cs
tf permission /deny:read myfile.cs /group:ADATAUM\Group1 ADATAUM\Group2 myfile.cs
See Also
Tasks
Control Access to Team Foundation Version Control
Undo Changes in Another User's Workspace
3/6/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 | TFS 2017 | TFS
2015 | VS 2017 | VS 2015 | VS 2013
Updated: October 2011
If a team member is blocked from checking in a file that is locked by someone else, you can use the tf undo
command to delete Team Foundation version control pending changes in another user's workspace.
If you must also remove an exclusive lock on a file, but not the pending changes, you can use the tf lock
command. For more information, see Lock Command.
If you must also delete another user's workspace, you can use the tf workspace command. For more
information, see Remove a Workspace.
Required Permissions
To undo pending changes in another user's workspace, you must have the Administer workspaces
permission set to Allow . For more information, see Permissions and groups reference.
To Undo the Changes in Another User's Workspace
1. Click Star t , click All Programs , click Microsoft Visual Studio 2010 , point to Visual Studio Tools ,
and then click Visual Studio 10.0 Command Prompt .
2. Type the following command at the command prompt and replace the arguments with the appropriate
parameter information for your needs:
tf undo /workspace:OtherUserWorkspace;OtherUser $/TeamProject/MyFile.cs
/collection:http://YourTFSServer:8080/tfs/YourCollection
Related articles
Create a Workspace to Work with your Project
Using the Check In and Pending Changes Windows
Working with Version Control Locks
Clean Up Files When Users Leave
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 | TFS 2017 | TFS
2015 | VS 2017 | VS 2015 | VS 2013
When a member leaves a team, version control administrators must correctly dispose of that member's files.
Required Permissions
To perform these procedures, you must be a member of the Team Foundation Administrators security
group. For more information, see Permissions and groups reference.
To clean up version-controlled files after a team member leaves
1. Check in any files that are checked out to the team member who has left.
NOTE
If the member's checked-out files do not need to be saved, omit this step.
See Also
Tasks
Remove a User From a Project or Project Collection
Configure Check-Out Settings
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 | TFS 2017 | TFS
2015 | VS 2017 | VS 2015 | VS 2013
Administrators of Team Foundation version control can configure source control check-out settings. Check-out
settings in Team Foundation version control enable files to be edited by more than one person at the same time.
The following procedure shows you how to configure check-out settings.
Required Permissions
To configure check-out settings, you must have the Edit project-level information set to Allow . For more
information, see Permissions and groups reference.
Procedure
To configure checkout settings
1. In Team Explorer , select the project for which you want to configure check-out settings.
2. From the Team menu, click Team Project Settings , and then click Source Control .
3. In the Source Control Settings dialog box, select the Check-out Settings tab.
4. Select or clear the Enable multiple checkout box.
5. Select or clear the Enable get latest on check-out box.
6. Click OK .
See Also
Tasks
Enable Team Foundation Version Control to Get the Latest Files on Check-Out
Use Team Foundation version control commands
3/6/2021 • 11 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 Star t , 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
T IP
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
c:\code\SiteApp\Main>tf get
/version:D2004-03-22T09:00
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
IM P O RTA N T
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.
O P T IO N O P T IO N A L IA S
/comment -C
/computer -M
/delete -D
/force -P
/format -F
/help -?, -H
/lock -K
/login -Y
/newname -N
O P T IO N O P T IO N A L IA S
/noprompt -I
/owner -O
/recursive -R
/ser ver -S
/slotmode -X
/template -T
/user -U
/version -V
/workspace -W
EXIT C O DE DEF IN IT IO N
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
3/6/2021 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
PA RA M ET ER DESC RIP T IO N
/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.
PA RA M ET ER DESC RIP T IO N
/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.
/teamproject: TeamProjectIdentifier Specifies the name of the project that contains the
permissions to view or modify.
/repositor y: RepositoryIdentifier Specifies the name of the repo that contains the permissions
to view or modify.
/branch: BranchName Specifies the name of the branch that contains the
permissions to view or modify. If you specify /branch , you
must also specify /repositor y .
/login: username,[password] Specifies the user account to run the command. See Use
Team Foundation version control commands.
See Git repository permission namespaces 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.
In this example we'll use the following collection, project, and repository:
/collection:https://fabrikam-fiber.visualstudio.com
/teamproject:FabrikamProject
/repositor y:FabrikamRepo
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).
tf git permission /allow:CreateBranch
/group:"[FabrikamProject]\Project Administrators"
/collection:https://dev.azure.com/fabrikam-fiber/
/teamproject:FabrikamProject
/repository:FabrikamRepo
/branch:master
Git view command
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
PA RA M ET ER DESC RIP T IO N
/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.
/repositor y: 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 .
PA RA M ET ER DESC RIP T IO N
/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 Ser ver 2020 | Azure DevOps Ser ver 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
PA RA M ET ER DESC RIP T IO N
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
11/2/2020 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
PA RA M ET ER DESC RIP T IO N
/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
/collection :TeamProjectCollectionUrl If you use the shelveset option, the /collection option
specifies the URL of the project collection that contains
the shelveset. 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.
PA RA M ET ER DESC RIP T IO N
/login :username,[password] Specifies the user account to run the command. See Use
Team Foundation version control commands.
N OT E
N OT E
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
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
3/6/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
PA RA M ET ER DESC RIP T IO N
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
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
PA RA M ET ER DESC RIP T IO N
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.
PA RA M ET ER DESC RIP T IO N
/version :versionspec Specifies the maximum version, or the minimum and the
maximum versions, to display in the history data. The
default is /version:T (the latest version).
For syntax, 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
11/2/2020 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
PA RA M ET ER DESC RIP T IO N
/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.
/sor t 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.
/user :username Filters the historical data to show changes made by the
specified user. An asterisk (* ) symbol includes data on
changes from all users (the default).
/version :versionspec Specifies one of the following limits on the history data:
The maximum version
The minimum and the maximum versions using
the range ~ syntax.
The default is /version:W (the version in the
workspace).
For syntax, see Use Team Foundation version control
commands.
You cannot combine this option with the /slotmode
option.
Examples
Get history of a single file
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 Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 | TFS 2017 | TFS
2015 | VS 2017 | VS 2015 | VS 2013
Displays information both about pending changes to files and folders and pending change candidates in one or
more workspaces. Or, when you use the /shelveset option, displays information about pending changes in a
shelveset.
NOTE
A pending changes candidate is a file in the workspace's folder or sub folder that wasn't added to version control. To view
all pending changes candidates in Visual Studio, go to Team Explorer > Pending Changes > Excluded Changes , and
then select Detected .
Parameters
A RGUM EN T DESC RIP T IO N
/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.
NOTE
itemspec Specifies the items for which you want pending change
data. For syntax, see Use Team Foundation version
control commands. You can specify more than one
itemspec argument.
/shelveset :shelvesetname[;shelvesetowner] Specifies the shelveset that contains the changes you
want to list.
This option cannot be combined with the /workspace
option.
NOTE
/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.
NOTE
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
11/2/2020 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
PA RA M ET ER DESC RIP T IO N
/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.
/workspace workspacename[;workspaceowner] Specifies the name of the workspace in which you want
to undo pending changes. If not specified, the
workspace is the one that maps the current directory.
You can specify workspaceowner to undo a pending
change 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. You
must have the UndoOther permission set to Allow to
undo changes in another user's workspace.
NOTE
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)
3/6/2021 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
O P T IO N DESC RIP T IO N
O P T IO N DESC RIP T IO N
/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.
txt 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
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 proper ties 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
A RGUM EN T DESC RIP T IO N
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.
O P T IO N DESC RIP T IO N
/version Specifies the version of the file to open for viewing the
properties on.
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.
Server path Indicates the full path of the item on the version control
server.
Last modified Indicates the date and time stamp for when the item
was last modified.
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)
3/6/2021 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
O P T IO N DESC RIP T IO N
O P T IO N DESC RIP T IO N
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.cs to 1254.cs.
The following example renames 314.cs to 1254.cs 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
3/6/2021 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
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/ ).
O P T IO N DESC RIP T IO N
/replace Replaces the existing shelveset with the same name and
owner as the one that you specify.
/delete Deletes the specified shelveset. Only the /ser ver 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
11/2/2020 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
O P T IO N DESC RIP T IO N
O P T IO N DESC RIP T IO N
/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
11/2/2020 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
@commentfile Specifies the path of a file that contains the comment that is
used for the branch.
O P T IO N DESC RIP T IO N
/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.
O P T IO N DESC RIP T IO N
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
3/6/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
O P T IO N DESC RIP T IO N
/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
3/6/2021 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
NoteFieldName=NoteFieldValue Sets the value of the check-in note field. You can provide
multiple, semicolon-separated "field=value" expressions.
username Provides a value to the /user option. You can specify this
argument as either Domain*UserName* or UserName.
O P T IO N DESC RIP T IO N
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
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 ser ver-level information permission set to Allow .
For more information, see Permissions and groups reference.
Parameters
A RGUM EN T DESC RIP T IO N
TeamProjectCollectionUrl The URL of the project collection that contains the project
that you specified (for example,
http://myserver:8080/tfs/DefaultCollection).
O P T IO N DESC RIP T IO N
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)
3/6/2021 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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 /keephistor y 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
A RGUM EN T DESC RIP T IO N
TeamProjectCollectionUrl The URL of the project collection that contains files that
you want to destroy (for example,
http://myserver:8080/tfs/DefaultCollection).
O P T IO N DESC RIP T IO N
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 /star tcleanup 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 /keephistor y , 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 /keephistor y , 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 /keephistor y 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
3/6/2021 • 8 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
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 (https://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 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
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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/).
O P T IO N DESC RIP T IO N
## 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.
c:\projects>tf dir /recursive $/
The following example lists all items and deleted items in the current folder together with their deletion IDs.
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
3/6/2021 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
O P T IO N DESC RIP T IO N
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.
N A M E M A SK DESC RIP T IO N
*.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.
C:>tf folderdiff $/serverFolder F:\localFolder /recursive /noprompt
See Also
Tasks
Compare Two Folders
View File Changes Using Annotate
Reconcile Differences Between Two Folders
Concepts
Folder Comparison Filters
Other Resources
Comparing Folders and Files
Tf Command-Line Utility Commands
Help Command (Team Foundation Version Control)
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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)
3/6/2021 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
Note
You can specify more than one Itemspec argument.
O P T IO N DESC RIP T IO N
/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.
Related articles
Command-Line Syntax (Version Control)
Labels Command
Unlabel Command
Use Labels to Take a Snapshot of Your Files
Use Labels to Take a Snapshot of Your Files
Tf Command-Line Utility Commands
Labels Command
3/6/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
TeamProjectCollectionUrl The URL of the project collection for which you want to
display the list of labels (for example,
http://myserver:8080/tfs/DefaultCollection).
O P T IO N DESC RIP T IO N
/owner Specifies the name of the user who owns the label. By
default, the owner is the person who applies the label.
Remarks
The labels command displays information about labels in the Team Foundation version control server. If you do
not specify a Team Foundation version control server, the Team Explorer tries to determine the Team Foundation
version control server based by using the current directory. If the current directory is not mapped to a Team
Foundation version control server, you must specify one by using the /s option.
By default, the results display the label name, owner and creation date for each label. If the format is changed to
"detailed," comments and the list of files and folders associated with each label are also displayed.
For links to other Team Foundation commands that provide additional information about the items in your Team
Foundation version control server and all of 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 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.
Related articles
Command-Line Syntax (Version Control)
Label Command (Team Foundation Version Control)
Unlabel Command
Informational Commands
Tf Command-Line Utility Commands
LocalVersions Command
3/6/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
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.
O P T IO N DESC RIP T IO N
O P T IO N DESC RIP T IO N
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.
c:\workspaces\FeatureA\catalog\>tf localversions . /recursive /format:detailed
Related articles
Informational Commands
Tf Command-Line Utility Commands
Lock Command
3/6/2021 • 5 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
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).
O P T IO N DESC RIP T IO N
O P T IO N DESC RIP T IO N
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.
Related articles
Command-Line Syntax (Version Control)
Checkout and Edit Commands
Status Command
Understanding Lock Types
Create a Workspace to Work with your Project
Tf Command-Line Utility Commands
Working with Version Control Locks
Merge Command
3/6/2021 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
source Specifies the file or folder to act as the source of the merge.
O P T IO N DESC RIP T IO N
/candidate Prints a list of all changesets in the source that have not
yet been merged into the destination. The list should
include the changeset ID that has not been merged and
other basic information about that changeset.
/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.
Note
Baseless merges cannot delete files in the target. You can
manually carry over such changes.
/conser vative Results in more conflicts when you merge one branch to
another.
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.
The following example discards all the changesets up to changeset 137 as a candidate for merging into branch2.
Related articles
Resolve Conflicts between Two Files
Command-Line Syntax (Version Control)
Branch Command
Merges Command
Tf Command-Line Utility Commands
Branching and Merging
Merges Command
3/6/2021 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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).
O P T IO N DESC RIP T IO N
/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.
Related articles
Command-Line Syntax (Version Control)
Merge Command
Branch Command
Informational Commands
Tf Command-Line Utility Commands
Branching and Merging
Msdn Command
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
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
11/2/2020 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
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.
A RGUM EN T DESC RIP T IO N
O P T IO N DESC RIP T IO N
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 the group "testers" to change their local copies of all items in $/testproject.
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.
Related articles
Command-Line Syntax (version control)
Tf Command-Line utility commands
Proxy Command
11/2/2020 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
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://ser ver :8081 ).
A RGUM EN T DESC RIP T IO N
O P T IO N DESC RIP T IO N
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 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.
See Also
Reference
Command-Line Syntax (Version Control)
Other Resources
Tf Command-Line Utility Commands
Reconcile Command
3/6/2021 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 | VS 2013
Compares the current state of the workspace on disk with the server's view, either to clean the workspace or to
promote unpended local changes.
Requirements: See Permissions and groups reference.
tf reconcile [itemspec]
/clean [/diff] [/noprompt] [/preview] [/recursive] [/ignore]
[/unmapped] [/exclude:itemspec1,itemspec2,...]
tf reconcile [itemspec]
/promote [/adds] [/deletes] [/diff] [/noprompt] [/preview]
[/recursive] [/noignore] [/exclude:itemspec1,itemspec2,...]
Parameters
A RGUM EN T DESC RIP T IO N
itemspec Used to identify the file or folder for which to apply the
reconcile command. If omitted, all suitable items will be
included. For more information about how Visual Studio
Team Foundation Server parses itemspecs to determine
which items are within scope, see Command-Line Syntax
(Version Control).
Note
You can specify more than one Itemspec argument.
O P T IO N DESC RIP T IO N
Note
Should specify /adds or(and) /deletes when using with
/noprompt .
O P T IO N DESC RIP T IO N
Note
Can be used with /promote only.
Note
Can be used with /promote only.
Note
This option overrides /ignore , /noignore and
/unmapped options in case of intersections.
Note
Can be used with /clean only.
Note
Can be used with /clean only.
O P T IO N DESC RIP T IO N
Note
Can be used with /promote only.
Remarks
You can use the reconcile command to synchronize your local workspace state with the server's one.
Use /clean to update the local workspace according to the server's state. Use /promote to promote locally
added and deleted items to pending changes in version control.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
Examples
Clean
The following example invokes the Clean Workspace dialog box so that you can specify local items that should
be deleted or redownloaded from the server.
tf reconcile /clean
The following example cleans all local items except ignored by version control.
The following example cleans all local items including unmapped and cloaked.
The following example cleans all items except "file1.txt" and "dir1" (with all its content).
tf reconcile /promote
The following example promotes all items including ignored by version control items, except the "myLib.dll" file.
The following example adds all locally created items to version control pending changes. This command works
similar to the tf add /noprompt command.
The following example adds all locally deleted items to version control pending changes.
See Also
Reference
Command-Line Syntax (Version Control)
Add Command
Get Command
Checkin Command
Difference Command
Concepts
Managing File Types
Other Resources
Tf Command-Line Utility Commands
Comparing Folders and Files
Resolve Command
3/6/2021 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
Note
You can specify more than one Itemspec argument.
Note
You cannot specify both an /overridetype and a
/converttotype .
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)
11/2/2020 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
Note:
You can specify more than one Itemspec argument.
O P T IO N DESC RIP T IO N
/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.
. . . A RO L L B A C K C H A N GE A N D T H E F O L LO W IN G A DDIT IO N A L
IF Y O U RO L L B A C K T H IS C H A N GE. . . C H A N GE A RE M A DE
edit edit
. . . A RO L L B A C K C H A N GE A N D T H E F O L LO W IN G A DDIT IO N A L
IF Y O U RO L L B A C K T H IS C H A N GE. . . C H A N GE A RE M A DE
encoding encoding
rename/move rename/move
delete undelete
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 /keepmergehistor y 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 /keepmergehistor y 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
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
O P T IO N DESC RIP T IO N
/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
11/2/2020 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
O P T IO N DESC RIP T IO N
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
11/2/2020 • 2 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
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.
O P T IO N DESC RIP T IO N
/recursive Unlabels all items in the particular directory and all the
subdirectories that match the itemspec.
Remarks
The unlabel command of the tf command-line utility removes an item from an existing label in the Team
Foundation version control server. For an introduction to labels, see Use Labels to Take a Snapshot of Your Files.
For information about how to assign a label to a set of files and folders, see Label Command (Team Foundation
Version Control).
If you remove all items from a label in the Team Foundation version control server, that label is deleted. You can
also delete a label using the command tf label /delete . To learn more about the existing labels in the system,
see Labels Command.
For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.
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
3/6/2021 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
O P T IO N DESC RIP T IO N
## 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.cs.
The following example displays the version of 314.cs that was checked in with changeset 1999.
The following example retrieves version 5 of 314.cs 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
11/2/2020 • 4 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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.
O P T IO N DESC RIP T IO N
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.
c:\projects>tf workfold $/projects/project_one C:\DifferentWorkfold
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
11/2/2020 • 6 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
O P T IO N DESC RIP T IO N
/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 director y 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
11/2/2020 • 3 minutes to read • Edit Online
Azure Repos | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 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
A RGUM EN T DESC RIP T IO N
O P T IO N DESC RIP T IO N
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
11/2/2020 • 6 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 or Team Administrators group. To get added, see Set permissions at the project
or collection level or Add Team Administrator.
To receive notifications, the Third-par ty 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 all Git repositories in a project, use the following slash command inside a channel:
The project URL can be to any page within your project (except URLs to repositories).
For example:
/azrepos subscribe https://dev.azure.com/myorg/myproject/
You can also monitor a specific repository using the following command:
The repository URL can be to any page within your repository that has your repository name.
For example, for Git repositories, use:
NOTE
You can subscribe only to public repositories.
3. The subscribe command gets you started with a default subscription. For Git repositories, the channel is
subscribed to the Pull request created event (with target branch = master), 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.
[!NOTE] Team administrators aren't able to remove or modify subscriptions created by Project administrators.
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 .
For example:
This command will delete all the subscriptions related to any repository in the project and removes the
repositories from the channel. Only project admins can run this command.
Command reference
The following table lists all the /azrepos commands you can use in your Slack channel.
SL A SH C O M M A N D F UN C T IO N A L IT Y
/azrepos subscribe [repository url/ project url] Subscribe to a repository or all repositories in a project to
receive notifications
/azrepos unsubscribe all [project url] Remove all repositories (belonging to a project) and their
associated subscriptions from a channel
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-par ty 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, reach out to us at Developer Community.
Related articles
Azure Boards with Slack
Azure Pipelines with Slack
Create a service hook for Azure DevOps with Slack
Azure Repos with Microsoft Teams
11/2/2020 • 7 minutes to read • Edit Online
If you use Microsoft Teams, you can use the Azure Repos app for Teams to easily monitor your repositories. Set
up and manage subscriptions to receive notifications in your channel whenever code is pushed/checked in or
when a pull request (PR) is created, updated or merged. The app supports monitoring both Git and Team
Foundation Version Control (TFVC) repositories.
Prerequisites
To create subscriptions for repository-related events, you must be a member of the Azure DevOps Project
Administrators group or Team Administrators group. To get added, see Set permissions at the project- or
collection-level or Add Team Administrator. To get added, see Set permissions at the project or collection
level.
To receive notifications, the Third-par ty application access via OAuth setting must be enabled for the
Azure DevOps organization, see Change application access policies for your organization.
To enable subscriptions, the project and/or repository must be public, see Make your project public or
private.
NOTE
Notifications are currently not supported inside direct messages.
You can only link the Azure Repos app for Microsoft Teams to a project hosted on Azure DevOps Services at this time.
The project URL can be to any page within your project (except URLs to repositories).
For example:
You can also monitor a specific repository using the following command:
@azure repos subscribe [repository url]
The repository URL can be to any page within your repository that has your repository name.
For example, for Git repositories, use:
NOTE
You can subscribe only to public repositories.
3. The subscribe command gets you started with a default subscription. For Git repositories, the channel
gets subscribed to the Pull request created event (with target branch = master). 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:
The subscription 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.
[!NOTE] Team administrators aren't able to remove or modify subscriptions created by Project administrators.
Using filters to get only notifications that you want
When a user subscribes to a repository using the @azure repos subscribe command, a default subscription is
created with no filters applied. Often, users need to customize these subscriptions to be notified only when
certain conditions are met. For example, users may want to get notified only when PRs have a particular group
added as reviewer.
The following steps demonstrate how to customize subscriptions.
1. Run the @azure repos subscriptions command.
2. In the list of subscriptions, if there is a subscription that is unwanted or must be modified, select Remove to
delete it.
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
NOTE
All the filters are typically drop-downs. However if the drop-down were to have greater than 100 items, then you will
need to enter the values manually.
For the TFVC Code Checked in event, the filter Under path must be of the format $/myproject/path .
For this feature to work, users have to be signed-in. Once they are signed in, this feature will work for all
channels in a Team.
For example:
This command will delete all the subscriptions related to any repository in the project and removes the
repositories from the channel. Only project admins can run this command.
Threaded notifications
To logically link a set of related notifications and also to reduce the space occupied by notifications in a
channel, notifications are threaded. All notifications linked to a particular pull request will be linked together.
Compact view of threaded notifications
Expanded view of threaded notifications
Command reference
The following table lists all the azure repos commands you can use in your Teams channel.
C OMMAND F UN C T IO N A L IT Y
@azure repos subscribe [repository url/ project url] Subscribe to a repository or all repositories in a project to
receive notifications
@azure repos signout Sign out from your Azure Repos organization
@azure repos unsubscribe all [project url] Remove all repositories (belonging to a project) and their
associated subscriptions from a channel
Multi-tenant support
In your organization if you are using a different email or tenant for Microsoft Teams and Azure DevOps, perform
the following steps to sign in and connect based on your use case.
Troubleshooting
If you are experiencing the following errors when using the Azure Repos App, 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-par ty 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 and sign in to https://teams.microsoft.com/ . Run the
@Azure Repos signout command and then run the @Azure Repos signin command in the channel where the
Azure Repos app for Microsoft Teams is installed.
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, please out to us at Developer Community.
Related articles
Azure Boards with Teams
Azure Pipelines with Teams
Launch Visual Studio via Azure DevOps Services
4/21/2021 • 2 minutes to read • Edit Online
To set up Visual Studio without Azure DevOps Services, learn how to get started. To host your own server,
learn how to install and set up Azure DevOps Server.
Azure DevOps Services 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
Services. If you want, you can also use Azure DevOps Services with any IDE or code editor, like the following
examples:
Eclipse, Android Studio, or IntelliJ
Xcode (see Git or TFVC)
Visual Studio Code
How do I set up Visual Studio 2015 for Azure DevOps Services when I
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 Services?
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 only need to add these details 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} .
Next steps
Add users to your organization
Related articles
Add code to Git or TFVC.
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
3/6/2021 • 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 migration with history.
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 | Out-File 'authors-transform.txt'
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> .
NOTE
Encoding can be adjusted by appending the -Encoding option to the command above, for instance,
OutFile 'authors-transform.txt' -Encoding utf8 .
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.
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 svn/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/svn/tags | % { $_.Replace('refs/heads/svn/tags/','') } | %
{ git tag $_ "refs/heads/svn/tags/$_"; git branch -D "svn/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.
Azure Boards & GitHub
4/2/2021 • 2 minutes to read • Edit Online
Azure Boards | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019
Use this guide to connect Azure Boards with one or more GitHub repositories.
By connecting Azure Boards with GitHub repositories, you enable linking between GitHub commits, pull
requests, and issues to work items. You can use GitHub for software development while using Azure Boards to
plan and track your work. Azure Boards provides the scalability to grow as your organization and business
needs grow.
If you haven't yet signed up for Azure Boards, you can do that now. See Sign up for free and invite others to
collaborate on your project. You can also sign up and sign in using your GitHub credentials.
In addition to accessing developer services such as Azure DevOps and Azure, you can use your GitHub account
to access all Microsoft online services, from Excel Online to Xbox.
By connecting Azure Boards with GitHub repositories, you enable linking between GitHub commits and pull
requests to work items. You can use GitHub for software development while using Azure Boards to plan and
track your work. Azure Boards provides the scalability to grow as your organization and business needs grow.
NOTE
Azure Boards and Azure DevOps Services support integration with GitHub.com and GitHub Enterprise Server repositories.
On-premises Azure DevOps Servers support integration with GitHub Enterprise Server repositories.
To connect Azure Boards to GitHub.com, connect and configure from Azure Boards. Or, alternatively, install and
configure the Azure Boards app from GitHub. Both methods have been streamlined and support authenticating
and operating via the app rather than an individual.
To connect Azure Boards to a GitHub Enterprise Server, see connect from Azure Boards.
Once you've configured the connection, you can then exercise these features:
Link GitHub commits and pull requests to work items
Configure status badges
Integration steps include:
Connect Azure Boards to GitHub Enterprise Server
Link GitHub commits and pull requests to work items
Configure status badges
Videos
Additional resources
Web portal navigation
Link work items
About work items
Process customization
About projects and scaling your organization
3/20/2021 • 11 minutes to read • Edit Online
Azure DevOps Ser vices | Azure DevOps Ser ver 2020 | Azure DevOps Ser ver 2019 | TFS 2018 - TFS
2013
A project provides a repository for source code and a place for users to plan, track progress, and collaborate on
building software solutions. A project represents a fundamental container where data is stored when added to
Azure DevOps.
When you create your project, a team of the same name is automatically created. This is sufficient for small
teams. However, for enterprise-level organizations, it may be necessary to scale up, to create additional teams
and projects. These additions can be created within the single account or collection.
The collection-project-team structure provides teams a high level of autonomy to configure their tools in ways
that work for them. It also supports administrative tasks to occur at the appropriate level. As your organization
grows, your tools can grow to support a culture of team autonomy and organizational alignment.
2. From there, you can choose a project from the set of projects listed.
To create or list projects, see Create a project
1. Select Azure DevOps to open Projects .
2. From there, you can choose a project from the set of projects listed.
1. Choose the name of the server.
2. From there, you can choose a project from the set of projects listed.
Limit user visibility for projects using the Project-Scoped Users group
By default, users added to an organization can view all organization and project information and settings.
The Limit user visibility for projects preview feature for the organization limits user access in two ways:
Restricting views that display list of users, list of projects, billing details, usage data, and more that is accessed
through Organization Settings .
Limiting the set of people or groups that appear through people-picker search selections and the ability to
@mention people.
IMPORTANT
The limited visibility features described in this section apply only to interactions through the web portal. With the REST
APIs or azure devops CLI commands, project members can access the restricted data.
Users and groups who are added to the Project-Scoped Users group can only see and select users and
groups in the project they are connected to from a people picker. To scope people pickers for all project
members, see Manage your project, Limit identity search and selection.
Historical data remains visible
Identities that have been added to a comment, discussion, or assignment continue to be visible to all project
members. For example, work items that were assigned to a user who has since left a project, the user’s name on
that work item remains visible to everyone in the project, even to users with the new restriction. The same is
true for @mentions in PRs, comments, discussions, and more.
Q&A
Q: Can I move or transfer a project to another organization or collection?
A: Not without losing data. You can't move a project from one collection/organization to another
collection/organization without losing data. You can manually copy resources and leave some behind, or use a
third-party tool, such as OpsHub Visual Studio Migration Utility, that copies data using the REST APIs.
Q: What programmatic tools support projects?
A. See Projects REST API.
Also, you can use the az devops project commands.
Related articles
Get started as an administrator
Web portal navigation
What do I get with a project?
Understand differences between Azure DevOps