Git & GitHub Interview Question #12

What does git add do?

Git Fundamentals, Repository, Working Tree, Staging, Commits & Branch Basics Junior Beginner

Quick Interview Answer

git add stages file content for the next commit. It can stage one file, selected paths, or a broader set of changes.

Detailed Explanation

git add stages file content for the next commit. It can stage one file, selected paths, or a broader set of changes.

Running git add does not create a commit and does not upload changes. It updates the index so the next commit can include the staged snapshot.

Code Example

git add README.md
git add src/
git add .