Git: the remote repository
Working with a remote repository: clone, origin, remote-tracking branches such as origin/main, fetch, pull, push and the rejection of a push that is behind.
- 25 cards
- 6 topics
- Free
The outline, topic by topic
Each topic is weighted the way the exam weighs it.
- Concepts
- Questions
- Sort and link
- The steps
- Scenarios
- Understand
A few cards from the deck
Remote repository: what is it?
Show the answer
A copy of the repository hosted elsewhere, on a server or a platform, which the team shares to exchange commits.
Each person keeps a full repository locally. Nothing is synchronised automatically: you exchange on demand, with fetch, pull and push.
The remote received two commits. After
git fetch, where is your main branch?- Unchanged: only origin/main moved
- Moved forward by two commits, like origin/main
- Merged with origin/main, with a merge commit
- Reset to the remote's state, your local commits are lost
Show the answer
Unchanged: only origin/main moved
fetch only updates the remote-tracking branches. It is then up to you to merge (or use pull) when you want to integrate those commits.
git … downloads a full repository with its history, and by default names the remote ….
Show the answer
git clone downloads a full repository with its history, and by default names the remote origin.
git remote -v lists the addresses of the configured remotes. “origin” is only a conventional name, which can be changed.
Remote-tracking branch (origin/main): what is it?
Show the answer
A local label that remembers where the remote's main branch was at the time of the last contact with it.
You do not move it yourself: only a fetch, a pull or a push updates it. It can therefore be behind the real remote.
Publishing your work when the remote has moved: which step comes after "git commit to record the work locally"?
- git pull fetches those commits and merges them into main
- Resolve any conflict and conclude the merge
- git push is accepted this time
- git push is rejected because the remote has extra commits
Show the answer
git push is rejected because the remote has extra commits
A push is only accepted if it merely moves the remote forward. The pull brings its commits to you, after which your history contains its own and the push goes through.