What is a git branch?

A git branch is a named bucket of commits. The name of the branch is always an alias to the top commit in the branch. When you have checked out a branch, every commit you make will be added to the branch. When you push or refer to a branch, you are pushing or referring to the top commit of the branch.

You can create a branch from any commit you are currently on by running git checkout -b [new-branch-name].

Tip
Remember that a commit is its history (among other things)? That means that when you push a branch to a remote, you are pushing all the commits in the branch to the remote, as well.

Remote branches

When you use git fetch to fetch information from a git remote into your local repo, all the branches (among other things) are copied into your local .git folder so you can access them without needing an internet connection. Note that git fetch on its own does not change your tracked files.

About branches

Only branches you have checked out or created locally will appear when you run git branch. To see all the branches available to you (including those that have been fetched from remotes but not checked out), you can use the -a flag, like:

git branch -a