0
0
Gitdevops~20 mins

Cloning a repository with git clone - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Clone Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of cloning a public Git repository
What is the output when you run git clone https://github.com/octocat/Hello-World.git in an empty directory?
Git
git clone https://github.com/octocat/Hello-World.git
Aerror: pathspec 'Hello-World' did not match any file(s) known to git
Bfatal: repository 'https://github.com/octocat/Hello-World.git' not found
C
Cloning into 'Hello-World'...
remote: Enumerating objects: 10, done.
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 100% (8/8), done.
Receiving objects: 100% (10/10), 2.5 KiB | 1.2 MiB/s, done.
Resolving deltas: 100% (3/3), done.
Dfatal: destination path 'Hello-World' already exists and is not an empty directory.
Attempts:
2 left
💡 Hint
Think about what happens when cloning a valid public repository into an empty folder.
🧠 Conceptual
intermediate
1:30remaining
Understanding git clone default behavior
When you run git clone https://github.com/user/repo.git without specifying a folder name, where does Git clone the repository?
AInto the current directory directly, overwriting existing files
BInto a new folder named 'repo' created in the current directory
CInto a hidden folder named '.repo' inside the current directory
DInto a temporary folder that is deleted after cloning
Attempts:
2 left
💡 Hint
Think about the folder Git creates by default when cloning.
Troubleshoot
advanced
2:00remaining
Error when cloning into a non-empty directory
You run git clone https://github.com/user/project.git existing_folder but get an error. What is the most likely cause?
AThe 'existing_folder' already exists and is not empty
BThe repository URL is invalid or misspelled
CYou do not have permission to access the repository
DGit is not installed on your system
Attempts:
2 left
💡 Hint
Git does not allow cloning into folders that already have files.
🔀 Workflow
advanced
2:30remaining
Cloning a repository with a specific branch
Which command clones only the branch named 'feature' from the repository https://github.com/user/repo.git?
Agit clone --branch feature --single-branch https://github.com/user/repo.git
Bgit clone --branch feature https://github.com/user/repo.git --depth 1
Cgit clone https://github.com/user/repo.git feature
Dgit clone --depth feature https://github.com/user/repo.git
Attempts:
2 left
💡 Hint
Use options to limit cloning to a single branch.
Best Practice
expert
3:00remaining
Choosing the best clone option for a large repository
You need to clone a very large repository but only want the latest commit history to save time and space. Which command is best?
Agit clone --bare https://github.com/user/large-repo.git
Bgit clone --single-branch https://github.com/user/large-repo.git
Cgit clone --recursive https://github.com/user/large-repo.git
Dgit clone --depth 1 https://github.com/user/large-repo.git
Attempts:
2 left
💡 Hint
Shallow clone limits history depth.