0
0
Gitdevops~20 mins

git commit with message - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Commit Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this git commit command?
You run the command git commit -m "Initial commit" after staging some files. What will git display?
Git
git commit -m "Initial commit"
Anothing to commit, working tree clean
B
[master (root-commit) abc1234] Initial commit
 3 files changed, 15 insertions(+)
Cfatal: no changes added to commit
Derror: commit message required
Attempts:
2 left
💡 Hint
Think about what happens when you commit after staging files.
💻 Command Output
intermediate
2:00remaining
What error does this git commit command produce?
You run git commit -m without providing a message. What error message will git show?
Git
git commit -m
Aerror: switch `m' requires a value
Bfatal: no commit message
Cerror: missing commit message after -m
Dnothing to commit, working tree clean
Attempts:
2 left
💡 Hint
The -m option expects a message string immediately after it.
🔀 Workflow
advanced
2:00remaining
Which command sequence correctly commits changes with a message?
You have modified files and want to commit them with the message "Update README". Which sequence is correct?
A
git add .
git commit -m "Update README"
B
git commit
git add .
git commit -m "Update README"
C
git commit -m "Update README"
git add .
D
git add .
git commit
Attempts:
2 left
💡 Hint
Remember you must stage files before committing.
Troubleshoot
advanced
2:00remaining
Why does this git commit command fail?
You run git commit -m "Fix bug" but get the message: fatal: no changes added to commit. Why?
Git
git commit -m "Fix bug"
AThe repository is corrupted
BThe commit message is too short
CNo files were staged before committing
DThe branch is not checked out
Attempts:
2 left
💡 Hint
Check if you used git add before committing.
Best Practice
expert
3:00remaining
Which git commit command correctly includes a multi-line message?
You want to commit with a title and a detailed description. Which command correctly does this?
Agit commit -m "Fix bug"; git commit -m "This fixes the issue with login timeout."
B
git commit -m "Fix bug
This fixes the issue with login timeout."
Cgit commit -m "Fix bug" --message "This fixes the issue with login timeout."
Dgit commit -m "Fix bug" -m "This fixes the issue with login timeout."
Attempts:
2 left
💡 Hint
Git allows multiple -m options for multi-line messages.