Share your code in Git using Eclipse

Share your code with your team with Visual Studio Team Services and Eclipse.

Before you start:

  1. If you don't have a Team Services account, create it first.

  2. If you have not yet connected to a team project in your Team Services account, do that now.

If your team project uses Git in your Visual Studio Team Services account, read on. However, if your team project uses TFVC in your Visual Studio Team Services account,then read Share your code in TFVC using Eclipse

Share using Git

Clone the repository

  1. Show the Git views.

    Windows menu, show window, other

    Select the repositories and staging views.

    Show view dialog box, Git expanded, Git Repositories and Git Staging selected

    If you don't have the Git views, you can get them by downloading EGit.

  2. Use the Git repositories view to clone the Git repository for your team project.

    Clone a Git repository link in the Git Repositories view

  3. Specify the URL for your project repository. The URL will look like http://{your_account}{your_team_project}

    Clone Git Repository dialog box with a team project URL and personal access token provided

  4. Specify where you'll keep the cloned repository on your machine. It's okay if your Git repository is empty.

    Local destination dialog box

    The repository for your team project shows up in the Git repositories view.

    Git repositories view showing the cloned repository

Push your code to the remote repository

  1. In Package Explorer, right-click the project and choose Team, Share Project.

    In the Package Explorer, the project's context menu, Team, Share Project

  2. Make sure you share it to Git.

    Share Project dialog box with Git selected

    Map the remote repository to your working directory.

    Configure Git Repository dailog box

  3. Add your files to the Git index to stage your changes.

    Git staging view, unstaged changes context menu,  Add to Git Index

  4. Enter a commit message and push the source to the remote repository.

    Use your personal access token for authentication.

    Commit and Push button in the Git Staging view

Your code is in your team project's Git repository, so now your teammates can contribute.

Try this next


Q: Where can I find the URL for my Git repository?

A: You'll find it in the code hub in your team project.

  1. Sign in to your Visual Studio Team Services account and browse to your team project or type the team project URL directly in your browser.
  • The URL will look like https://{your_account}{your_team_project}

  • If you are not sure about your team project URL, Sign in to your Visual Studio and select your account.

  1. Open the code hub from your you team project's home page.

    Team project home page, code explorer

  2. Select the the repository and click on the clone action to get the URL.

    Team project home page, code explorer, clone selected to show the URL

Q: Why should I use personal access tokens?

A: Personal access tokens are a more convenient and secure replacement for alternate authentication credentials.

Q: Why can't connect to my Git repo?

A: To use Git with your Visual Studio Team Services account, create a personal access token so that you can sign in from Eclipse.

  1. Sign in to your Visual Studio Team Services account (http://[youraccount]

  2. Go to your team project's home page and open your profile.

    Team project home page, my profile

  3. Create a new personal access token for this account.

    Add a personal access token on the security page

  4. Enter the details for this token.

    Enter token details

  5. Select the scopes that this token authorizes.

    Select scopes for this token

  6. After you finish creating the token, make sure to copy the token. You'll use this token as the password.

    Use token as password for your git tools or application

    Note: Remember that these tokens are your identity. When used, the token is acting as you. Keep your tokens secret and treat them like your password. To help keep your token more secure, consider using credential stores so that you don't have to enter your credentials every time you push.

    Some available credential stores:

    For example, if you use the Git command prompt to run a Git command, you'll be prompted for a username and password.

    git clone https://[account][team project]

    Enter a username that does not contain an @ character (for example, Jamal, not Use the token that you created as your password.

    Username for '': Jamal
    Password for '': [COPY THE TOKEN HERE]
  7. When you don't need your token anymore, just revoke it to remove its access.

Q: Can I still use alternate authentication credentials?

A: Yes.

  1. Sign in to your Visual Studio Team Services account (http://[youraccount]

  2. Go to your team project's home page and open your profile.

    Team project home page, my profile

  3. Enable alternate authentication credentials for this account. Then provide a secondary username and password.

    Enable alternate authentication credentials link on the user profile page

Q: What if the Git views don't show up.

A: You can download EGit to use Git with Eclipse.

Q: Can I use my GitHub repository instead of Visual Studio?

A: Yes, provide the name of your GitHub repository in Step 3 under "Clone the repository" above instead of the name of your VSTS repository.