init & clone
Start a new repo or copy an existing one
Skills taught: git.init, git.clone, git.repository
git init — start tracking a folder
# Navigate to your project folder
cd my-project
# Initialise a Git repository
git init
# → Initialized empty Git repository in /path/to/my-project/.git/
# OR create a new folder and init in one step
git init my-new-project
cd my-new-project
# See the hidden .git folder (use -a to show hidden files)
ls -a
# → . .. .git
The .git folder is Git's database — it stores your entire history. Don't delete or edit it manually.
git clone — download an existing repo
# Clone from GitHub (HTTPS — easier for beginners)
git clone https://github.com/prashantkeshr/KERNAL.git
# Clone from GitHub (SSH — more secure, no password prompts)
git clone git@github.com:prashantkeshr/KERNAL.git
# Clone into a specific folder name
git clone https://github.com/user/repo.git my-folder
# Shallow clone — only last 1 commit (faster for large repos)
git clone --depth 1 https://github.com/user/repo.git
# After cloning:
cd KERNAL
git remote -v # shows the 'origin' remote was set up automatically
The typical new-project workflow
# 1. Create folder and init
mkdir my-website && cd my-website
git init
# 2. Create your first file
echo '# My Website' > README.md
# 3. Stage and commit (covered next lesson)
git add README.md
git commit -m "Initial commit"
# 4. Create a repo on GitHub, then add it as remote
git remote add origin https://github.com/yourname/my-website.git
# 5. Push
git push -u origin main
Frequently Asked Questions
What is the difference between HTTPS and SSH cloning?
HTTPS (https://github.com/...) is simpler — use your GitHub username and a personal access token as the password. SSH (git@github.com:...) uses a key pair stored on your machine — more secure and no password prompts once set up. SSH is recommended for developers who push often.
Can I accidentally overwrite an existing repo with git init?
Running git init in an already-tracked folder is safe — it just re-initializes. It won't delete history. But avoid running it inside another repo's subfolder unless you intentionally want a submodule.