Git - Notes


remote
remote repository
upstream
upstream branch, tracking branch, remote-tracking branch
origin
name for the remote a project was originally cloned from

upstream

  1. https://stackoverflow.com/a/37770744/3632318

https://git-scm.com/book/id/v2/Git-Branching-Remote-Branches

Checking out a local branch from a remote branch automatically creates what is called a “tracking branch” (or sometimes an “upstream branch”). Tracking branches are local branches that have a direct relationship to a remote branch. If you’re on a tracking branch and type git pull, Git automatically knows which server to fetch from and branch to merge into.

When you clone a repository, it generally automatically creates a master branch that tracks origin/master.

list all local branches and their upstream branches (if any):

$ git branch -vv

say, you create a new branch and push it into remote repository:

$ git checkout -b foo
$ git push

NOTE: if remote repository is not specified, it defaults to origin.

this is what happens as a result:

$ git branch -avv
  master                d87ad32 [origin/master] misc
* foo                   d87ad32 misc
  remotes/origin/master d87ad32 misc
  remotes/origin/foo    d87ad32 misc

there 2 ways to set upstream: