Cloning a repository from GitHub downloads a complete local copy of the project, including its full commit history and all branches, and automatically sets up a remote connection back to the source.
Key Points: • On the repository's GitHub page, the "Code" button provides the HTTPS or SSH URL needed to clone it. • git clone <url> downloads all files and the entire commit history into a new local directory named after the repository. • Git automatically configures a remote named origin pointing back to the URL you cloned from. • You can clone into a custom directory name by passing it as a second argument to git clone. • SSH URLs avoid repeated password prompts if you've set up an SSH key with GitHub, while HTTPS is simpler to get started with.
Example: Copying the URL https://github.com/example/project.git from the Code button and running git clone https://github.com/example/project.git creates a local project folder with the complete history and an origin remote already configured.
Code Example:
git clone https://github.com/example/project.gitInterview Tip: A concise interview answer is:
"I copy the repository URL from GitHub's Code button and run git clone with that URL, which downloads the full history into a new local folder and sets up origin automatically. From there I can branch, commit, and push right away."