0
0
Gitdevops~5 mins

Shallow clones with depth in Git - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a shallow clone in Git?
A shallow clone is a copy of a Git repository that contains only the latest commits up to a specified depth, not the full history. It saves time and space.
Click to reveal answer
beginner
How do you create a shallow clone with a depth of 5 commits?
Use the command: git clone --depth 5 <repository_url>. This clones only the last 5 commits.
Click to reveal answer
beginner
Why would you use a shallow clone?
To save time and disk space when you only need recent history, such as for quick builds or testing, not full project history.
Click to reveal answer
intermediate
Can you fetch more history after a shallow clone?
Yes, you can deepen the clone later using git fetch --deepen <number> or fetch the full history with git fetch --unshallow.
Click to reveal answer
beginner
What is the difference between a shallow clone and a full clone?
A full clone downloads the entire commit history, while a shallow clone downloads only a limited number of recent commits.
Click to reveal answer
Which command creates a shallow clone with a depth of 3 commits?
Agit clone --depth 3 <repo_url>
Bgit clone --shallow 3 <repo_url>
Cgit clone --limit 3 <repo_url>
Dgit clone --history 3 <repo_url>
What is a main benefit of using shallow clones?
AAutomatic branch creation
BAccess to full project history
CAbility to push changes faster
DFaster cloning and less disk space used
How can you get more commits after a shallow clone?
Agit fetch --deepen <number>
Bgit clone --depth <number>
Cgit pull --shallow
Dgit reset --depth <number>
Which of these is NOT true about shallow clones?
AThey save time when cloning
BThey can be deepened later
CThey include the full commit history
DThey download fewer commits
What happens if you run git fetch --unshallow?
AIt deletes the shallow clone
BIt converts a shallow clone into a full clone by downloading all history
CIt reduces the depth of the clone
DIt creates a new shallow clone
Explain what a shallow clone is and why it might be useful.
Think about cloning only recent changes instead of everything.
You got /3 concepts.
    Describe how to create a shallow clone and how to get more history later.
    Start shallow, then deepen or unshallow as needed.
    You got /3 concepts.