Starting a Repo & Identity

Creating a Repository

Turn any ordinary folder into a Git repository with one command:

$ git init
Initialized empty Git repository in /home/labuser/project/.git/

That single command creates a hidden .git/ directory inside the folder. *That folder is the repository - every commit, branch, and piece of history you'll ever create lives inside it as plain files. Everything else in the folder (your actual code) is just the working copy* Git is watching. Delete .git/ and the history is gone forever, but the folder itself just goes back to being an ordinary, untracked directory.

Tip: Run ls -la right after git init if you're curious - you'll see the new .git entry sitting alongside your normal files. You never need to open or edit anything inside it by hand.

Before your very first commit, Git needs to know who you are, because every commit gets permanently stamped with an author name and email:

$ git config --global user.name  "Your Name"
$ git config --global user.email "you@example.com"
CommandPurpose
git initStart tracking the current folder
git config --global user.nameSet your commit name
git config --listShow current config
git clone <url>Copy an existing remote repo (its files and its history)
Tip: --global sets your identity for every repo on your machine, written into ~/.gitconfig. Drop --global and run the same command inside a specific project to override it just for that one repo - handy for keeping a work email separate from a personal one.
Warning: A classic beginner trap: running git init inside a folder that's already inside another Git repo (for example, accidentally running it in your home directory, or inside a subfolder of a project you already initialized). This creates a nested, orphaned repository that behaves strangely. If git status ever surprises you by not showing files you expect, check with git rev-parse --show-toplevel to confirm which repo root you're actually in.

Try it below: git init a folder, then set a name and email, and confirm with git config --list.