Join us December 10-11, 2024
| Developer Experience + AI Conference
Register now free →
Search
Close this search box.

How do you set an upstream branch in Git?

If you have a remote branch, you likely have a local branch with the same name. A typical workflow is to first make commits locally and then push those changes to the remote branch.

However, sometimes you need to push to a different remote branch. In order to do this in Git, you will need to change the upstream of your local branch to your new target remote branch. 

“I use @GitKraken because I can concentrate on getting the job done rather than trying to remember the commands and trying to imagine how the branches connect.” – @palmiak_fp

How do you set an upstream branch in GitKraken?

With GitKraken, it’s easy to locate a branch and change the upstream in Git to push, pull, or fetch from  a different Git branch.

Right-click on a branch to set the upstream or click the ellipsis icon.

git-set-upstream-branch-gitkraken

Alternatively, you can drag-and-drop a branch from the central graph in GitKraken to push instead of setting upstream.

git-set-upstream-branch-drag-and-drop

Daily Git actions, like push, pull, fetch, and setting upstream are easier with GitKraken, thanks to the incredible visual context offered by the central graph. You’ll always know what’s going on with your commits, branches, and remotes. 💥

How do you set an upstream branch in Git using the command line? 

To set the upstream branch in Git, use the following command:

$ git push --set-upstream <remote> <branch>

This will push your local branch to the new remote branch.

Additional Resources

Table of Contents

Make Git Easier, Safer &
More Powerful

with GitKraken

Visual Studio Code is required to install GitLens.

Don’t have Visual Studio Code? Get it now.

Team Collaboration Services

Secure cloud-backed services that span across all products in the DevEx platform to keep your workflows connected across projects, repos, and team members
Launchpad – All your PRs, issues, & tasks in one spot to kick off a focused, unblocked day. Code Suggest – Real code suggestions anywhere in your project, as simple as in Google Docs. Cloud Patches – Speed up PR reviews by enabling early collaboration on work-in-progress. Workspaces – Group & sync repos to simplify multi-repo actions, & get new devs coding faster. DORA Insights – Data-driven code insights to track & improve development velocity. Security & Admin – Easily set up SSO, manage access, & streamline IdP integrations.
winget install gitkraken.cli