Back

Blog

Git Commands

Simple git commands and what they do.

Start tracking a project

Run this once when you first create a new project folder. It tells Git to start watching this folder for changes.

git init

See what changed

Shows you which files you edited, added, or deleted since your last save. Use this anytime you are not sure what Git sees.

git status

Stage all your changes

Gets all your changed files ready to save. Staging is like putting items in a shopping basket before you check out.

git add .

Stage one file

Only gets one specific file ready to save. Replace filename with the actual file name, like index.html.

git add filename

Save a snapshot

Saves your staged changes with a short note so you remember what you did. Replace the message in quotes with your own words.

git commit -m "your message here"

See your save history

Lists all the snapshots you have saved, newest first. Useful when you want to see what you worked on before.

git log

Copy a project from GitHub

Downloads a project from GitHub onto your computer. Replace the URL with the link from the green Code button on GitHub.

git clone https://github.com/username/repo-name.git

Connect to GitHub

Links your local project to a GitHub repository. Run this once after creating a new repo on GitHub. Replace the URL with your repo link.

git remote add origin https://github.com/username/repo-name.git

Upload your code (first time)

Sends your saved commits to GitHub for the first time. The -u flag means future pushes can just use git push.

git push -u origin main

Upload new saves

After your first push, use this to send any new commits to GitHub.

git push

Download the latest code

Pulls down any changes from GitHub that you do not have yet. Good to run before you start working if others are on the same project.

git pull