0
0
Gitdevops~20 mins

Why staging before committing matters in Git - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Staging Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why use staging area before commit?

What is the main purpose of the staging area in Git before committing changes?

ATo merge branches before committing
BTo permanently delete unwanted files from the repository
CTo selectively choose which changes to include in the next commit
DTo automatically push changes to the remote repository
Attempts:
2 left
💡 Hint

Think about how you prepare a photo album by picking only some pictures before printing.

💻 Command Output
intermediate
2:00remaining
Output of git status after staging

What will git status show after you run git add file.txt but before committing?

Git
git add file.txt
git status
AChanges to be committed: new file: file.txt
BUntracked files: file.txt
CNothing to commit, working tree clean
DChanges not staged for commit: modified: file.txt
Attempts:
2 left
💡 Hint

After adding, the file is ready to be saved in the next commit.

🔀 Workflow
advanced
2:00remaining
Correct sequence to stage and commit changes

Which sequence of commands correctly stages and commits a file named app.py with a message 'Add app script'?

A
git commit -m 'Add app script' app.py
git add app.py
B
git add app.py
git commit -m 'Add app script'
C
git commit app.py
git add -m 'Add app script'
D
git add -m 'Add app script' app.py
git commit
Attempts:
2 left
💡 Hint

Remember: add first, then commit with message.

Troubleshoot
advanced
2:00remaining
Why commit does not include recent changes?

You modified index.html but after running git commit -m 'Update', the changes are not saved in the commit. What is the likely reason?

AYou forgot to stage the changes with <code>git add index.html</code>
BThe commit message is too short
CThe file is ignored by .gitignore
DYou need to push before committing
Attempts:
2 left
💡 Hint

Think about how you must tell Git which changes to save.

Best Practice
expert
3:00remaining
Why commit small, focused changes after staging?

What is the main benefit of staging and committing small, focused changes instead of one big commit?

AIt reduces the size of the repository on disk
BIt speeds up pushing to the remote repository
CIt automatically merges branches without conflicts
DIt makes it easier to review, understand, and revert specific changes later
Attempts:
2 left
💡 Hint

Think about how organizing photos by event helps find them later.