Git Clone and Init

Start a repo from scratch or copy a remote repository locally.

  • git clone
  • git init
  • shallow clone
  • git remote
  • clone branch

Git Clone and Init

Start a repo from scratch or copy a remote repository locally.

Commands

CommandWhat it does
git initCreate a new repo in the current directory
git clone <url>Copy a remote repo locally
git clone --depth 1 <url>Shallow clone: latest snapshot only, much faster
git clone -b <branch> <url>Clone and check out a specific branch
git remote -vList remote URLs (fetch/push)

Example

git clone --depth 1 https://github.com/example/app.git
cd app
git remote -v

FAQ

Shallow clone vs full clone?

Shallow (--depth 1) downloads only the latest snapshot; full history is needed for blame/log archaeology.

How do I change the remote URL?

Use git remote set-url origin <new-url>, then verify with git remote -v.

SSS

Shallow clone vs full clone?
Shallow (--depth 1) downloads only the latest snapshot; full history is needed for blame/log archaeology.
How do I change the remote URL?
Use git remote set-url origin <new-url>, then verify with git remote -v.

Git