CodeBlanks Logo Icon CodeBlanks

Summary - Commit

Combine add and commit to record the first snapshot.

Save Your First Snapshot

Before your first commit, you add files to the staging area with git add. Then use git commit -m to save these changes to the repository history with a descriptive message.

git add index.html
git add style.css
git commit -m "Create first page"

Practice Build the First Commit Command Sequence

Stage home.html and main.css with separate commands. Then use git commit -m with the message Save the first design. Store all three commands in an array in order and print each on a separate line.

Starter code

terminal
// Komut dizisini oluştur
let workflow = [];

// Dosyaları sahneleme ve commit komutlarını ekle

// Komutları ekrana yazdır

Sample solution

terminal
let workflow = [
  'git add home.html',
  'git add main.css',
  'git commit -m "İlk tasarımı kaydet"'
];

workflow.forEach(item => console.log(item));

Expected output

git add home.html
git add main.css
git commit -m "İlk tasarımı kaydet"

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which is the correct sequence for the first commit?

  • git add → git commit Correct answer
  • git config → git commit → git add
  • git commit → git add
  • git status → git config → git add

Explanation: First, changes are staged with <code>git add</code>, then saved with <code>git commit</code>.

2 Complete the First Commit Message

Question
git add index.html
git commit -m ____
Answer
git add index.html
git commit -m "İlk sayfayı oluştur"

Explanation: The commit message is provided in quotation marks after the <code>-m</code> option.

3 Match the First Commit Flow

Term Meaning
git add Stage a file
staging_area Changes prepared for saving
git commit Save the snapshot
message Describe the commit

All lessons in Beginner