Skip to main content

Site links

  • Agency for web development
  • Content Management with Primer
  • Open Source Leadership with Drupal
Language
DeutschEnglish

Secondary navigation

  • Contact
Agentur für Webentwicklung

Hauptnavigation

  • References
  • Services
  • Blog
  • About us

Site links

  • Agency for web development
  • Content Management with Primer
  • Open Source Leadership with Drupal
close

Breadcrumb

  1. Home
  2. Blog
  3. Techblog Archive

Upstream handling in Git

29. August 2011
Sascha Grossenbacher Porträt
Sascha Grossenbacher

Explicit reference

When no default upstream is defined (see below) or you want to pull from or push to a different upstream, you can always specify it directly. When pushing:


git push
# For example:
git push origin master

# You can also push all branches
git push origin --all

And for pulling, it works exactly the same way.

git pull
# For example:
git pull origin master

You can also pull and push from local branches, just leave the remote away.

However, always having to specify this can be quite tedious, especially if you're not always working with the default names (remote origin and master branch) or are working with multiple branches. To solve this problem, git allows to set a default upstream for each branch. When cloning a remote repository, git will automatically set the default upstream to the repository you cloned from. But that doesn't happen when a new repository is initialized locally or the default upstream needs to be changed. Git provides two ways to define that default upstream location explicitly.

During push

The -u flag for git push allows to tell git the the default upstream is now the branch you are pushing to.

git push -u new_origin master

Git will then automatically report that the upstream has been set to this location.

Using git branch --set-upstream

That command allows you to change the default upstream without having to execute a push command. The command is used like this:

git branch --set-upstream /
# For example:
git branch --set-upstream master new_origin/master

About MD Systems

MD Systems, headquartered in Zurich, is a unique team of international open source initiative leaders for the Drupal content management system.

With our experts for software architecture and design and our industry solutions, you digitize your organization successfully and efficiently.

MD Systems GmbH

Hermetschloostrasse 77, CH-8048 Zürich

Schweiz

+41 44 500 45 95

[email protected]

Fußzeile

  • Contact
  • Impressum
  • Data protection
To top

© Copyright 2017 - 2018 MD Systems GmbH. Alle Rechte vorbehalten. Erstellt mit PRIMER - powered by Drupal.