Summary - Staging
- Git course
- Beginner
- Lesson 20/80
- 5 min
Combine the add command to stage multiple files.
Stage Multiple Files
To stage multiple files individually, specify each file path with a separate git add command. This lets you choose which files will be prepared for a commit.
git add index.html
git add style.css
git statusPractice Build a Two-File Staging Flow
Add commands that stage index.html and style.css separately to an array. Add git status as the final command, then print all commands line by line.
Starter code
// Komut listesini oluştur
let commands = [];
// Komutları sırayla ekle
// Komutları sırayla yazdırSample solution
let commands = [
'git add index.html',
'git add style.css',
'git status'
];
commands.forEach(command => console.log(command));Expected output
git add index.html git add style.css git status
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which approach correctly stages two files with separate commands?
- Use a separate git add command for each file Correct answer
- Configure both files with git config
- Select the files directly with git commit
- Run git status for both files
Explanation: You can stage files individually by using a separate <code>git add</code> command for each file.
2 Complete the Multiple File Staging Command
git add index.html
________________
git add index.html
____________git add style.css
Explanation: A new <code>git add</code> command is used to stage the second file as well.
3 Match the Multiple File Staging Flow
| Term | Meaning |
|---|---|
index.html |
First staged file |
style.css |
Second staged file |
git add |
Add a file to staging |
git status |
Check file status |