Your first commits
Create a repository, stage changes and save snapshots.
Git is a version control system. It stores snapshots of your project, called commits, so you can see what changed, go back in time and work with others without overwriting each other.
One-time setup
git config --global user.name "Ana Lopez"
git config --global user.email "ana@example.com"The three areas
- Working directory: the files you edit.
- Staging area: the changes you picked for the next commit.
- Repository: the saved history of commits.
The basic loop
git init # start a repository in this folder
git status # what changed?
git add index.html # stage one file (or "git add ." for everything)
git commit -m "Add home page" # save a snapshot with a message
git log --oneline # list the historyNoteWrite messages that say why or what, in the imperative: "Fix login redirect", not "stuff". Your future self reads them.
Ignoring files
List files that must never be tracked, such as node_modules/ or .env with secrets, in a .gitignore file at the root of the project.
CarefulNever commit passwords or API keys. Once pushed, assume they are public even if you delete them later: rotate the key.
Test yourself
Answer all the questions, then check them. Finish with every answer right to mark the lesson as done.