Compartir a través de


Share code with push

TFS 2017 | TFS 2015 | TFS 2013

Visual Studio 2019 | Visual Studio 2017 | Visual Studio 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

Share your code with push

Note

Visual Studio 2019 version 16.8 and later versions provide a new Git menu for managing the Git workflow with less context switching than Team Explorer. Procedures provided in this article under the Visual Studio 2019 tab provide information for using the Git experience as well as Team Explorer. To learn more, see Side-by-side comparison of Git and Team Explorer.

  1. In Team Explorer, select Home and then choose Sync to open Synchronization.

    Synchronization

    You can also go to Synchronization from the Changes view by choosing Sync immediately after making a commit.

    Go to Synchronization from the Changes view immediately after making a commit.

  2. Select Push to share your commit with the remote repository.

    Push

    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 > Repository Settings. Make sure that you've entered the correct User, Email, Remotes, and other settings.

Resolve merge conflicts before pushing

If there are conflicts between your local commits and the remote branch, you must resolve these conflicts before you can push your changes. Pull the changes from others first. You can resolve the conflicts and commit the changes, then try the push command again.

Next steps