Git & GitHub Interview Question #37
What is a remote-tracking branch?
Remotes, Fetch, Pull, Push, Merge, Conflicts, Rebase & Stash Junior Beginner
Quick Interview Answer
A remote-tracking branch is a local reference that records Git's last known state of a branch in a remote repository. Names such as origin/main and origin/develop are common examples.
Detailed Explanation
A remote-tracking branch is a local reference that records Git's last known state of a branch in a remote repository. Names such as origin/main and origin/develop are common examples.
You do not normally commit directly to origin/main. Your local main branch and the origin/main remote-tracking reference are separate references that may point to different commits until synchronization occurs.
Code Example
git fetch origin
git branch -r
git log --oneline main..origin/main