CodeBlanks Logo Icon CodeBlanks

Summary - Staging

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 status

Practice 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

terminal
// Komut listesini oluştur
let commands = [];

// Komutları sırayla ekle

// Komutları sırayla yazdır

Sample solution

terminal
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

Question
git add index.html
________________
Answer
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

All lessons in Beginner