Staging & Committing Code (git add, git commit, git branch)
Concept & Overview
In Git version control, modifications made to working files must be staged before they can be committed into repository history.
- git add : Stages modified files into the index (e.g., git add server.js), preparing them for commit.
- git commit -m ": Records a permanent snapshot of staged changes with a descriptive message (e.g., git commit -m "Fix config").
- git branch: Lists all local repository branches and indicates the currently active branch with an asterisk.
git add server.js, commit it using git commit -m "Fix config", and inspect active branches by running git branch.Command Syntax Reference
| Command / Syntax | Description |
|---|---|
git add server.js | Stage modified file for commit |
git commit -m "Fix config" | Record snapshot with commit message |
git branch | List local git branches |
Verification Objectives
These conditions will be automatically verified when you run commands inside the interactive terminal simulator:
- ○Stage server.js with git add server.js
- ○Commit changes with git commit -m
- ○Check branches with git branch
Ready to complete Quest 148?
Test your skills live in the browser terminal with an emulated Linux filesystem, real-time command evaluation, and instant step-by-step hints.