git set-upstream branch code example

Example 1: git set upstream

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

// short version to set upstream with very first push
git push -u origin local-branch

Example 2: github set branch upstream

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

Example 3: git set upstream repository

$ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

Example 4: git local branch track remote

git branch --set-upstream foo upstream/foo