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
| Command | What it does |
|---|---|
git init | Create 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 -v | List 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
Git Config Essentials
Set identity, defaults, and aliases for Git on a new machine.
Git Add and Commit
Stage changes and record them as commits with clear messages.
Git Branch Basics
Create, list, rename, and delete branches for parallel work.
Git Switch and Checkout
Move between branches and restore files without losing work.