Hone

Lessons · Git · copying a whole repository

Getting a copy of a project

git clone URL copies a repository, full history included, into a new folder, and names the source remote origin.

Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.

What it is for

It is the first command on any existing project. A clone is a complete repository: you can read every commit, make branches and commit offline, and push when you are back.

How to think about it

Clone, cd in, run git remote -v to see where it came from and git log --oneline to see the history you now hold. For a huge project, --depth 1 takes only the latest commit.

Worked example

git clone https://example.com/team/app.git
A full copy, history included, into a folder named app.
cd app && git remote -v
origin, twice: where you fetch from and push to.
git log --oneline -3
The history came with it; you can work offline.

Your turn

Get a copy of the project.

git  https://github.com/org/repo.git

The trap

A clone is the whole history, not a snapshot. Cloning a huge repository is slow; --depth 1 takes only the latest commit when that is all you need.

Practise copying a whole repository on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.