Which command restores a file from the staging area back to the working directory, discarding staged changes?

Syntax:
git restore --staged (filename)
Example:
git restore --staged index.html

Note: It will successfully execute if the file is in the staged area; otherwise, it will throw an error stating "did not match any files."

Which command shows all references (branches, tags, remotes) along with their commit IDs?

git show-ref

Which command creates a new branch named 'feature-x'?

git checkout -b feature-x
or
git switch -b feature-x

How do commits help in tracking changes within a Git repository?

Commits are the backbone of Git’s change-tracking system. Each commit acts like a snapshot of your project at a specific point in time, recording what changed, who made the change, and why. This allows Git to maintain a complete history of the project, making collaboration and rollback possible.

What is the purpose of the .git folder inside a Git repository?

The .git folder is the hidden directory that makes a project a Git repository. It stores all the metadata, commit history, branches, and configuration data Git needs to track and manage your project. Without it, your folder is just a regular directory with files.