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 initSee 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 statusStage 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 filenameSave 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 logCopy 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.gitConnect 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.gitUpload 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 mainUpload new saves
After your first push, use this to send any new commits to GitHub.
git pushDownload 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