What is git clone?
Why Interviewers Ask This
This is a classic screening question for Git & GitHub roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.
Answer
git clone creates a local copy of a remote repository, including the full history, all branches, and all files. Syntax: git clone <url> [directory]. Examples: git clone https://github.com/user/repo.git — clones into a folder named "repo"; git clone https://github.com/user/repo.git myproject — clones into "myproject". What clone does: (1) Creates a new directory; (2) Initializes a .git/ repository; (3) Downloads all objects and refs from the remote; (4) Creates a remote tracking reference called origin pointing to the URL; (5) Checks out the default branch. Clone options: --depth 1 — shallow clone (only latest commit, no full history — faster for large repos in CI/CD); --branch feature-x — clone and checkout a specific branch; --recurse-submodules — also clone submodules. Protocols: HTTPS (easiest, prompts for password or token), SSH (git@github.com:user/repo.git — key-based, no password), Git protocol (read-only, rarely used). After cloning, origin is automatically configured as the remote.
Common Mistake
Rushing to answer is a common mistake. Take two seconds to structure your response: definition → example → trade-off. This structure makes complex Git & GitHub answers easy to follow.