📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials Git & GitHub Git Init and Clone

Git Init and Clone

4 min read
Create new repos with git init or clone existing repos with git clone and add remotes.

Creating and Cloning Repositories

# Start a new repo
mkdir myproject && cd myproject
git init
git init --initial-branch=main

# Clone an existing repo
git clone https://github.com/user/repo.git
git clone https://github.com/user/repo.git my-folder
git clone --depth=1 https://github.com/user/repo.git  # shallow clone

# Add remote
git remote add origin https://github.com/user/repo.git
git remote -v
git remote set-url origin git@github.com:user/repo.git