Share code with push

Last Update: 1/23/2017
Team Services | TFS 2015 & TFS 2017 | Visual Studio 2015 & 2017

Overview

Share changes made in commits and branches using the push command. Push your branches to the remote repository, where Git takes the commits and adds them to an existing branch on the remote or creates a new branch with the same commits as your local branch.

Git makes sure that pushed changes are consistent with the remote branch so others can pull your commits and merge them into their own local copy of the branch. Pushed branches that have finished work are reviewed and merged into the main branch of the your repo through a pull request.

Video overview

Share your code with push

Team Services | TFS 2015 & 2017 | Visual Studio 2015 & 2017

In Team Explorer, open the Sync view. The view lists outgoing commits and will present you with one of two links to push them to your remote repo:

  • Publish when there is not a branch on the remote repo associated with the current local branch. This will create a branch with the same name on the remote repo and push the commits to it. Later you will Push, not publish changes when using this branch since the relationship between the branch on the local branch and the remote repo exists.
  • Push when there is a relationship between the local branch and the remote repo. Clicking this will push the commits to the remote branch.

    Pushing Changes with Git in Visual Studio

The push command will update the remote branch on origin with the commits from your local branch.

> git push
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 861 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Analyzing objects... (3/3) (114 ms)
remote: Storing packfile... done (62 ms)
remote: Storing index... done (53 ms)
If the remote branch doesn't exist, run the following to create a remote branch on origin.
> git push -u origin users/frank/bugfix

Your commits on your local branch are added to the branch on origin, and a upstream tracking relationship will be set up in Git so that next time you push (or pull) from this local branch, you won't have to specify the remote branch name.

Resolve merge conflicts before pushing

If there are conflicts between your local commits on the commits on the remote branch, you must first resolve these conflicts before you can push your changes. You should pull the changes from others first, resolve the conflicts and commit the changes, then re-attempt the push.

What's next

Review code with pull requests or update code with fetch and pull