Git - Upstream Branch (origin)

> Code - (Programming|Computer) Language > Code Versioning > Git

1 - About

An upstream is the remote branch of a tracking branch.

It defines the original repository that was forked.


3 - Shorthand

@{u} or @{upstream} means the upstream branch of the current branch

  • @{upstream}
  • or @{u}

Usage example with the merge command

git merge @{u}

4 - Management

4.1 - Set

# Set the upstream config as you push
git push -u origin master
git push --set-upstream origin master
# or 
git branch -u origin/branchName
# or
git branch --set-upstream-to origin/branchName
Branch branchName set up to track remote branch branchName from origin.

4.2 - Diff

4.2.1 - Local Branch vs upstream

  • Description
git log HEAD..@{u} --oneline
71bfc15 (origin/master) Added ansible-config cli
c4c7124 Added ansible-inventory
  • Count
git rev-list HEAD...@{u} --count

4.2.2 - Upstream vs local branch

git log @{u}..HEAD --oneline
afc0e4b (HEAD -> master) private key enhancement

5 - Support

5.1 - fatal: no upstream configured for branch 'master'

Example on the master branch

git branch --set-upstream-to origin/master
code/version/git/upstream.txt · Last modified: 2019/09/11 22:07 by gerardnico