0
0
Gitdevops~20 mins

git commit -a to skip staging - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Commit Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What does git commit -a do?

You have modified some tracked files in your Git repository but have not staged them. You run git commit -a -m "Update files". What happens?

AGit shows an error because you must stage files manually before committing.
BGit commits only the files that were already staged before running the command.
CGit commits all files in the repository, including untracked files.
DGit stages all modified tracked files automatically and commits them with the message "Update files".
Attempts:
2 left
💡 Hint

Think about what the -a flag does in git commit.

🧠 Conceptual
intermediate
1:30remaining
Which files are included when using git commit -a?

When you run git commit -a, which files are automatically staged and committed?

ANo files are staged automatically; you must stage manually.
BOnly modified and deleted tracked files are staged and committed.
COnly new untracked files are staged and committed.
DAll files in the working directory, including new untracked files, are staged and committed.
Attempts:
2 left
💡 Hint

Remember what 'tracked' means in Git.

Troubleshoot
advanced
2:00remaining
Why does git commit -a not include new files?

You ran git commit -a -m "Add changes" but noticed your new files were not committed. Why?

ABecause <code>git commit -a</code> only stages modified and deleted tracked files, not new untracked files.
BBecause you need to use <code>git commit -am</code> without space to include new files.
CBecause new files are ignored by default and cannot be committed.
DBecause <code>git commit -a</code> commits only staged files, and new files are staged automatically.
Attempts:
2 left
💡 Hint

Think about how Git tracks files and what -a does.

🔀 Workflow
advanced
2:00remaining
What is the correct workflow to commit all changes including new files quickly?

You want to commit all your changes, including new files, with minimal commands. Which sequence is best?

ARun <code>git add .</code> to stage all changes, then <code>git commit -m "message"</code>.
BRun <code>git add -u</code> then <code>git commit -a -m "message"</code>.
CRun <code>git commit -m "message"</code> without staging anything.
DRun <code>git commit -a -m "message"</code> to commit all changes including new files.
Attempts:
2 left
💡 Hint

Remember how to include new files in commits.

Best Practice
expert
2:30remaining
Why might using git commit -a be risky in a team environment?

Consider a team project where multiple developers work on many files. Why could relying on git commit -a be risky?

ABecause it only commits untracked files, ignoring modifications.
BBecause it does not commit any changes and causes confusion.
CBecause it commits all modified tracked files automatically, which might include unintended changes.
DBecause it requires manual staging of all files before committing.
Attempts:
2 left
💡 Hint

Think about control over what gets committed.