Git for Beginners: Your First Repository
A step-by-step guide to creating a Git repository, making your first commit, and pushing to a remote
Git is a tool that tracks changes to your files over time. Every time you save a snapshot, called a commit, Git records what changed and who made the change. This means you can go back to any previous state, see the full history of a project, and collaborate with others without overwriting each other's work.
This guide walks through setting up Git and creating your first repository from scratch.
Step 1: Configure Git
Before your first commit, tell Git your name and email. These are attached to every commit you make.
git config --global user.name "Your Name"
git config --global user.email "you@example.com"You only need to do this once per machine. To confirm the settings saved correctly, run:
git config --listStep 2: Create a Local Repository
Navigate to the folder where your project lives (or create a new one), then run:
mkdir my-project
cd my-project
git initgit init creates a hidden .git folder inside the directory. That folder is where Git stores the entire history of your project. Do not delete or move it.
Step 3: Create a File and Check the Status
Create a simple file:
echo "# My Project" > README.mdNow ask Git what it sees:
git statusGit will report that README.md is an untracked file. That means Git knows it exists but is not tracking changes to it yet.
Step 4: Stage the File
Staging means telling Git which changes you want to include in your next commit. Stage the file:
git add README.mdTo stage everything in the current folder at once:
git add .Run git status again and you will see the file is now listed under "changes to be committed."
Step 5: Make Your First Commit
A commit saves the staged changes to the history with a message describing what you did:
git commit -m "Add README"Write commit messages in the present tense and keep them short but descriptive. After running this, git log will show your first commit with its unique identifier, your name, your email, and the timestamp.
Step 6: Connect to a Remote Repository
A remote is a copy of your repository stored somewhere else, typically on a hosting service. Create an empty repository there first (do not add any files during setup), then connect it:
git remote add origin https://github.com/yourname/my-project.gitorigin is the conventional name for the main remote. Confirm it was added:
git remote -vStep 7: Push to the Remote
Send your local commits to the remote:
git push -u origin mainThe -u flag sets the upstream tracking, so future pushes can be done with just git push. If your default branch is called master instead of main, use that name.
Worked Example: Full Flow
# One-time setup
git config --global user.name "Ana Silva"
git config --global user.email "ana@example.com"
# Create the project
mkdir store-site
cd store-site
git init
# Add a file
echo "My store website" > README.md
git add README.md
git commit -m "Initial commit"
# Connect and push
git remote add origin https://github.com/ana/store-site.git
git push -u origin mainFrom here, the daily workflow is: make changes, git add, git commit -m "message", git push.
More setup guides
Not sure your computer can run a model? Use the will-it-run checker.

