Fetch and Remote-Tracking References
Observe before integrating
After Alice commits milk.txt and pushes, Bob’s origin/main may still describe the earlier commit. It is a local reference, not a live server view. Fetch updates configured tracking refs without integrating the current branch in this normal clone.
git fetch origingit log --oneline main..origin/maingit diff main origin/mainThe incoming commit and milk.txt appear in the inspection; Bob’s working files and main remain unchanged.
Read the mapping
A refspec maps a source reference to a destination. The normal clone fetch mapping uses refs/heads/* on the remote and refs/remotes/origin/* locally. Its leading plus permits non-fast-forward updates of those tracking refs, not of your local main.
git config --get remote.origin.fetchgit rev-list --left-right --count main...origin/maingit ls-remote --heads origin mainExpected counts: 0 and 1 before integration in the lab. ls-remote queries the actual remote; it does not refresh origin/main.
Practice and check
Use the Chapter 10 lab guide. Before each command predict which local or remote reference changes, then compare the observed result. Explain fetch without changing the current working branch.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Fetch and Remote-Tracking References — knowledge check
Check understanding of remote repository behavior.
After normal fetch, which tip can change without integrating?
Why can origin/main be stale?
What does main..origin/main list with log?
What does ls-remote query?
What does a refspec describe?