The week’s first issue, next week’s deals, belongs to the store’s back office. That’s where the weekly ad arrives, and the computer there has so far only printed price labels. To work on the site from there, that computer needs its own copy of the project, with the whole history and a connection to GitHub.
In this lesson, you’ll set up that second copy from GitHub. You’ll choose the right repository URL, find out what a fresh copy brings along and what it leaves behind, and get the site running there. Start on GitHub.
Clone the Repository From GitHub
You don’t need a second computer for this course. A second folder on your own computer stands in for the back-office computer, and Git treats it exactly as it would a copy on another machine. Changes to the project travel between the two folders only through GitHub. The folders do share your computer’s own Git setup, such as your name, email, and saved token. A real second computer would need that setup once, too.
Before you copy anything, make one small change on GitHub. Real projects have more branches on GitHub than main, but yours doesn’t, because the vite branch from the last course never left your laptop. To see what a fresh copy does with other branches, create a short-lived one on GitHub:
-
Open your
generic-groceryrepository on GitHub. -
Click the branch menu above the file list, the one that says main.
-
Type
back-office-testin the Find or create a branch… field. -
Click the option that starts with Create branch, which makes
back-office-testfrommain.
The new branch points at the same commit as main, and you won’t commit anything to it. It’s only there so you can see how it arrives in the copy, and you’ll remove it again in the next lesson.
Now get the repository’s address. Go back to the repository’s main page and click the green Code button. On its Local tab, GitHub offers two types of addresses, HTTPS and SSH:
-
An HTTPS URL,
https://github.com/..., signs in with your login and a token. That’s the token your credential helper already keeps forgithub.com, so pushes from the new folder won’t ask for it. -
An SSH URL,
[email protected]:..., signs in with an SSH key instead. You’d first create a key pair on your computer, add only its public key to your GitHub account, and keep its private key on your computer. Your token doesn’t help there.
The URL you copy determines how Git signs in every time it talks to GitHub from that copy. Choose HTTPS and copy the address, which looks like the one you added as origin on your laptop:
https://github.com/generic-grocery-dev/generic-grocery.git
The same menu also offers Download ZIP, which looks like a quicker way to get the project. That ZIP holds only the files of the latest commit, with no .git folder. It has no history, no other branches, and no remote, and Git answers fatal: not a git repository in it. The course’s starter ZIP was different, because it was packed with its .git folder on purpose, but even that one didn’t know about any GitHub repository.
The command that makes a full copy is git clone. A clone is a complete copy of a repository, with every commit of every branch, that remembers where it came from. In the terminal in your laptop’s generic-grocery folder, move up one folder so the copy lands next to it, and clone with your own URL and a folder name for the back office:
$ cd ..
$ git clone https://github.com/generic-grocery-dev/generic-grocery.git generic-grocery-backoffice
Cloning into 'generic-grocery-backoffice'...
remote: Enumerating objects: 138, done.
remote: Counting objects: 100% (138/138), done.
remote: Compressing objects: 100% (66/66), done.
remote: Total 138 (delta 69), reused 117 (delta 66), pack-reused 0
Receiving objects: 100% (138/138), 39.59 KiB | 19.80 MiB/s, done.
Resolving deltas: 100% (69/69), done.