Commit flow
- Git course
- Beginner
- Lesson 78/80
- 6 min
Add multiple files and create commits with meaningful messages.
Work with Multiple Files
You can modify multiple files in a project. You can use git add with multiple filenames to prepare them for the same commit.
git add index.html style.cssSaving the prepared changes under one meaningful commit helps keep your project history organized.
Practice Prepare Two Files Together
Prepare index.html and style.css for the same commit. Then print a message confirming preparation is complete.
Starter code
print("Dosyalar kontrol edildi")Sample solution
git add index.html style.css
print("İki dosya hazırlandı")Expected output
Dosyalar kontrol edildi İki dosya hazırlandı
Practice Create Meaningful Commit Messages
First add index.html and create a commit with the message Homepage added. Then add style.css and create a second commit with the message Page styles added.
Starter code
print("İlk kayıt hazırlanıyor")Sample solution
git add index.html
git commit -m "Ana sayfa eklendi"
git add style.css
git commit -m "Sayfa stilleri eklendi"
print("İki commit tamamlandı")Expected output
İlk kayıt hazırlanıyor İki commit tamamlandı
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which command is suitable when you want to prepare two files for the same commit?
- git init index.html style.css
- git branch index.html style.css
- git add index.html style.css Correct answer
- git commit index.html style.css
Explanation: Correct. You can use git add to stage multiple files at the same time.
2 Add Multiple Files
git add index.html ____
git add index.html style.css
Explanation: You can list filenames separated by spaces in the git add command.
3 Parts of the Commit Workflow
| Term | Meaning |
|---|---|
git status |
Displays changes |
git add . |
Stages the current folder |
-m |
Commit message option |
git commit |
Records staged changes |