Collaborate in a Git team project (pull, push)

When you collaborate on Team Foundation Server (TFS), your team uses version control integrated with other powerful capabilities such as planning and tracking projects and automated CI and scheduled builds. You can create a Git team project on either an on-premises server that you set up yourself, or on one that we maintain for you on Visual Studio Online. Or, if you prefer, you can collaborate in remote Git repositories hosted by third-party services such as CodePlex, GitHub, or Bitbucket.

  • Fetch commits from your team

  • Pull commits from your team

  • Push to contribute your changes with the team

  • Push to an alternate remote

  • Conduct a Git pull request (for an on-premises team project you must first install Team Foundation Server Update 4)

  • Browse the team project

  • Subscribe to alerts

  • Work in a team project with multiple repositories

  • Q & A

  • Take next steps

Fetch commits from your team

If you want to preview the changes from your team before you integrate them into your work, from the commits page (Keyboard: Ctrl + 0, O), fetch commits from your team project.

Fetch link on Commits page

After you fetch a commit, to get more information, open its context menu and choose View Commit Details.

Note

You must also fetch before you can get a copy of a branch that someone on your team has published.

Pull changes from your team

When you are ready to integrate changes from your team into your local repository, in Team Explorer, go to the commits page (Keyboard: Ctrl + 0, O). Pull any commits that might have been pushed by your team.

Commits page with Fetch and Pull highlighted

If conflicts occur…

Conflicts sometimes occur when you try to pull

you must resolve them before you can proceed.

Push to contribute your changes with the team

When you are ready to contribute your committed changes to the team’s remote Git repository, push them from the commits page (Keyboard: Ctrl + 0, O).

Pushing the commits

Note

You must pull remote changes before push

If your team has pushed commits to the branch since you last cloned or pushed, then you must first pull all the changes from the remote repository before you can push your changes into it.

Push to an alternate remote repository

In some cases, you might want to push to an alternate remote repository. (You must have installed Visual Studio 2013 Update 2 or a subsequent version to use this feature.)

For example, you are developing a web site in a Git team project. You want to publish the web site to Windows Azure, so you add your Windows Azure site as a remote repository. When you are ready to publish the site, you can push to it.

Push To link on Unsynced Commits page

Note

This option is available only in Visual Studio 2013 Update 2 and appears only if your Git repository has more than one remote. To add a remote, open the Git command prompt and then use the git remote command. See also: Git-SCM: Git Basics - Working with Remotes

Browse the team project

To browse the team project, open it in your web browser (Keyboard: Ctrl + 0, A).

On the Home page, choose Web Access

Exploring a TFS Git repository in web access

  1. Explore the files

  2. View the commit history

  3. Work with branches

Explore the files

Before you explore the files, specify the branch or tag you want to use to filter the view.

You can filter the view by branch or by tag

On the Explorer page, browse the file tree and view each file. You can also see who changed what in each file.

Annotated changes to a file on web portal

You can also:

  • Get the URL to clone the repository. (You don’t need a URL to clone a repository from Visual Studio, but you might need it if you want to clone from the Command Prompt or from a third-party Git client tool.)

    Copying the URL to manually clone a repository in

  • Download an individual file and download a folder as a .zip file

  • Perform an Advanced search for a specific commit based on path, user (the author of the commit), and date

Subscribe to alerts

Do you want to be notified when someone pushes code into your Git team project? Subscribe to receive email alerts. Here’s how.

Alerts web portal page in Git team project

Work in a team project with multiple repositories

You can add additional repositories to your Git team project. Later, you can rename or delete them as needed. One benefit of working this way is that you can re-use process template customizations, such as those you’ve made to your work item type definitions, across multiple codebases.

To manage the Git repositories in your team project, open it in your web browser (Keyboard: Ctrl + 0, A).

Manage Git repositories

Create a new repository when you need one (for example, to develop a new app).

New repository link on version control web portal

In Visual Studio, select the repository in which you want to work.

Connect page, Git team project with multiple repos

Q & A

Q: I was blocked by the system because I don’t have permission. How do I get it?

A: Permission reference for Team Foundation Server

Q: How do I work from the command prompt?

A:Work from the Git command prompt.

Q: How do I pull and push in a single step?

A: Choose the Sync button.

Q: Can I modify the structure of my local commits (for example squash multiple commits into a single commit) before I push my changes?

A:Work from the Git command prompt.

How do I view, alter, or roll back my committed changes?

A:

Q: When I tried to pull I was blocked by conflicts. How do I resolve them?

A:Resolve Git conflicts.

Q: Can I use My Work or code reviews with Git?

A: No.

Q: Why is Push not available?

A: One common reason Push is unavailable is if you are working in a branch that you have not yet published. Switch to the Branches page (Keyboard: Ctrl + 0, N) if you want to publish the branch.

Q: When should my team add a new repository?

This decision is subjective. Many people believe that you should keep each repository to a reasonable size. When the codebase grows to a certain point, they split it into multiple repositories. Some teams believe each app should have its own repository.

Q: Is it OK to commit binaries?

In general, you should avoid committing binaries, especially large ones. An alternative way to get binaries that your app depends on is to use NuGet.

Next Steps

Collaborate with your team in your team project