Remotes, Without a Server · practice
Clone the Shared Repository
origin.git now contains the same two-main history as garden. A clone turns that
Clone the repository
git clone takes a repository location and a destination directory. It creates the destination, copies the reachable Git history, checks out a working tree, and records the source under the conventional remote name origin.
The cd means change directory. cd .. moves up to the parent directory, while cd garden-copy enters the named directory inside the current one. It changes where later commands run; it does not move files or switch Git branches.
First move from /workspace/garden to /workspace so all three repositories are siblings. Then clone from the relative origin.git path into garden-copy and enter that new directory:
cd ..
git clone origin.git garden-copy
cd garden-copy
This clone is an observation repository for the chapter: you will inspect and fetch in it, but every new commit will be made in the prepared garden repository.
Correct a remote’s saved location
Look at what the clone recorded as origin and you will find the full path /workspace/origin.git, not the origin.git you typed. Git expanded it.
That is worth fixing, and the command that fixes it is one you will want again. Repositories move: a project gets relocated on disk, a server changes address, a team migrates from one host to another. When that happens the location saved under origin is simply wrong, and git remote set-url is how you correct it. It takes the remote’s name and the replacement location.
git remote set-url origin ../origin.git
Now both repositories describe origin.git the same way, as the sibling directory it is. This changed a saved setting and nothing else: no commit moved, no file changed, and the clone still points at the same bare repository it did a moment ago.
Inspect what clone created
Run the verbose remote listing you learned earlier, then read both refs:
git remote -v
git log main
git log origin/main
git status
git remote -v should show ../origin.git. Local main and origin/main both start at the seeded List the first plants commit. The working tree contains README.md and plants.txt, and it is clean.
The names are local to this clone. Its main is not garden’s main, and its origin/main is not a live view into the bare repository. Each repository stores its own refs. They agree now because cloning copied the current state.
What does origin/main inside garden-copy represent immediately after the clone?
Three repositories now hold the same two commits, and each one keeps its own private set of names for them. That independence is the entire point of the arrangement, and it stays invisible for exactly as long as all three agree. In the next lesson one of them moves ahead.