What is git commit?
Why Interviewers Ask This
This question tests conceptual clarity. Interviewers want to hear a precise, confident definition before moving to more complex Git & GitHub topics. It also reveals how well you can explain technical ideas to non-experts.
Answer
git commit saves the staged changes as a permanent snapshot in the repository history. Each commit has: a unique SHA-1 hash, author name and email, timestamp, commit message, a pointer to its parent commit(s), and a snapshot of the staged files. Variants: git commit -m "message" — commit with inline message; git commit — opens your configured editor to write a message; git commit -am "message" — automatically stage all tracked modified files and commit (skips git add for modified files, but NOT new untracked files); git commit --amend — modify the most recent commit (change message or add forgotten files). Good commit message practices: (1) Subject line ≤50 chars, capitalized, imperative mood ("Fix bug" not "Fixed bug"); (2) Blank line separating subject from body; (3) Body explains WHAT and WHY, not HOW; (4) Reference issue numbers. Commits are immutable once pushed and shared — --amend and rebase should only be used on commits not yet pushed.
Pro Tip
Back up your answer with a specific project or situation. Saying 'In my last Git & GitHub project, I used this when...' immediately makes your answer more credible and memorable.