Skip to content

Instantly share code, notes, and snippets.

@irfanandriansyah1997
Forked from hackjutsu/upstream.md
Created September 12, 2018 17:09
Show Gist options
  • Select an option

  • Save irfanandriansyah1997/90bd1b1fea07f66bae6f805750f68bff to your computer and use it in GitHub Desktop.

Select an option

Save irfanandriansyah1997/90bd1b1fea07f66bae6f805750f68bff to your computer and use it in GitHub Desktop.
[set upstream] What does '--set-upstream' do? #tags: git
git branch --set-upstream-to <remote-branch>
# example
git branch --set-upstream-to origin feature-branch

# show up which remote branch a local branch is tracking
git branch -vv

sets the default remote branch for the current local branch.

Any future git pull command (with the current local branch checked-out), will attempt to bring in commits from the into the current local branch.

One way to avoid having to explicitly do --set-upstream is to use the shorthand flag -u along-with the very first git push as follows

git push -u origin local-branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment