Understanding Git clone, push and fetch
origin/main is a pointer in your local repository that tracks where that branch sits on a remote server. These remote reference pointers (bookmarks) are the key to understanding Git collaboration.
The cheatsheet
Cloning a repository
git clone <repository-url>
Downloads a copy of the remote repository, and adds a remote branch pointer called origin/main.
Checking which remote you’re attached to
git remote -v
Shows the remote counterpart of your local repository. By default Git calls your remote repo origin. Therefor origin/main refers the branch named main in the origin repository.
Seeing which branches track a remote
git branch -vv
Shows which of your local branches track a remote branch.
Downloading commits from a remote
git fetch origin
Reaches out to the remote repository and downloads any commits you don’t have yet. The origin/main pointer advances; but your local branch pointer does not.
Uploading your commits
git push origin main
Uploads the commits on your local main branch into the origin repository’s main branch, then advances origin/main pointer.
Logging commits you’re missing
git log origin/<branch>
Lists any commits on the remote reference. origin/main is just another branch, so ordinary branch commands are fair game.
Going further
Check out this post on Git pull vs fetch.
