Git tracks every change to your project so you can review history and undo mistakes. GitHub hosts Git repositories online so you can back them up, share them and collaborate.
One-time setup
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
Start tracking a project
cd my-project
git init # create a repository
git status # see what changed
git add . # stage all changes
git commit -m "First commit"
Put it on GitHub
- Create an empty repository on github.com.
- Connect your local project and push:
git branch -M main
git remote add origin https://github.com/your-name/my-project.git
git push -u origin main
The everyday loop
git add .
git commit -m "Describe what you changed"
git push
Working on a branch
git switch -c new-feature # create and switch to a branch
# ...edit and commit...
git push -u origin new-feature
Then open a pull request on GitHub to review and merge the branch.
Tip: commit small, focused changes with clear messages. Never commit passwords or API keys; list secret files in
.gitignore.