Cloning Made Easy: Try degit and Clone Directories within Repos.

Kunal Singh

Jul 19, 2023

Have you ever faced the dilemma of wanting just a small portion of a repository, but ended up cloning the whole thing? Well, worry no more! Today, I'm here to share an exciting solution that will save you time and disk space. Let's dive into the world of degit, an incredible npm package that will revolutionize the way you work with repositories!

The Dilemma: Cloning vs. Snippet Hunting

Have you ever tried cloning an entire repository when you only needed a specific subdirectory or file? It can be frustrating, right? You end up with a bunch of unnecessary code cluttering your workspace and wasting precious time. But fear not, degit is here to rescue you!

Meet degit: The Subdirectory Magician

degit is a lightweight, powerful tool that allows you to download just the parts of a repository you truly need. With degit, you can say goodbye to tedious cloning and hello to selective downloading!

How does it work?

Using degit is as easy as pie! Simply install it globally with npm:

npm install -g degit

Once you have degit at your fingertips, it's time to work some magic! To download a specific subdirectory from a repository, use the following command:

# Command Format
degit <repo> <destination> [--branch <branch>] [--force]

# these commands are equivalent
degit github:user/repo
degit git@github.com:user/repo
degit https://github.com/user/repo

# download from GitLab
degit gitlab:user/repo
degit git@gitlab.com:user/repo
degit https://gitlab.com/user/repo

# download from BitBucket
degit bitbucket:user/repo
degit git@bitbucket.org:user/repo
degit https://bitbucket.org/user/repo
  • <repo>: The URL of the repository you want to download from.
  • <destination>: The directory where you want to save the subdirectory.
  • [--branch <branch>] (optional): Specify a particular branch of the repository.
  • [--force] (optional): Overwrite any existing files in the destination directory.

Downloading Subdirectories from Git Repos

Imagine you stumble upon a fantastic GitHub repository, but all you need is a tiny piece of it. With degit, your wish is its command! Just grab the URL of the repository, specify the subdirectory you desire, and voilà! degit will fetch it for you in a jiffy.

No more cloning entire repositories, no more wasting precious disk space. degit empowers you to embrace the minimalist approach and download only what you need.

degit https://github.com/GoogleChrome/chrome-extensions-samples/functional-samples/sample.page-redder

Could I BE any happier if you found this post helpful? 😄

Chandler-bing-dancing GIFs - Get the best GIF on GIPHY

If you learned something new today, share it with your pals who could benefit from it too!

Got any questions? Let's connect on LinkedIn, tweet me on Twitter, or simply drop me a line. I'll be there for you, like a reliable npm package!

Connect with me on LinkedIn | Tweet me at Twitter | Visit @singhkunal2050 | Write me here.

Happy Coding!!

Recommendations

This One HTML Attribute Could Save Your Web App from a Security Nightmare

#web-security

,

#cdn

,

#web

Web security is a critical concern for developers, yet some of the most...

Jun 29, 2024

Are You Still Using Basic CSS? Here Are 7 Tricks to Get Ahead of the Curve

#css

Bored of the same old CSS? Unleash 7 hidden gems to take your designs to the...

Dec 27, 2023

Easiest way to store your logs in a file WITHOUT chaging the source file(node)

#productivity

Often, developers face challenges when dealing with a flood of logs in the...

Dec 21, 2023

Build Your Own Pinterest-Style Masonry Grid: A Step-by-Step Guide

#css

,

#web

,

#layout

Create a masonary grid layout with left to right content flow, supporting...

Dec 10, 2023

Using git diff and git apply to Share Local Changes with Peers

#git

,

#productivity

,

#software_engeneering

,

#dev

git diff and git apply are two powerful Git commands that can be used to share...

Nov 12, 2023

React Portals: Render Components Outside the current DOM Hierarchy

#react

,

#web

The createPortal API in React allows you to render child elements into a...

Jul 27, 2023

Debugging Web Apps with Browser Dev Tools: 6 Amazing Tricks

#browser

,

#debugging

,

#web

Debugging web applications can be a challenging task, with errors like...

Jul 13, 2023

Controlled Versus Uncontrolled Components in React

#react

,

#forms

Understanding State Management Within Forms Comparing controlled and...

Nov 5, 2022

Format Numbers, Dates and Currencies with the Intl Object in Javascript

#javascript

,

#html

,

#web

Intl object can be used to format data into commonly used formats of dates,...

Sep 13, 2022

Image Masking on Hover Using CSS Clip Path and Javascript

#javscript

,

#css

,

#html

Image Masking can be used to add fancy hover highlight effects to images for...

Jul 23, 2022

Recreating CSS Tricks Fancy Grid Hover Effect

#html

,

#css

,

#UI

,

#recreation

CSS Trick had a simple yet cool grid layout which I found dope. So lets try to...

May 21, 2022

File Explorer Recursive React Component

#react

,

#javascript

,

#web

How to create a recursive folder Component using react.

Apr 16, 2022

Add Google Fonts to Your React & NextJS + TailwindCSS Project (Next 14)

#css

,

#tailwindcss

,

#react

,

#nextjs

,

#tailwind

,

#design

Use Google Fonts in Your TailwindCSS Projects

Apr 6, 2022

Event Delegation in Javascript

#javscript

,

#css

,

#html

,

#web

,

#performance

Handling multiple Events in Javascript with minimal CPU Usage

Mar 6, 2022

A Simple Web Accessibility Trick that you most probably missed!

#html

,

#css

,

#web-accessibility

,

#user-experience

Imagine that you cannot use the mouse and have to Navigate a Website with the...

Dec 23, 2021

Top Terminal Commands I Use For Productivity

#linux

,

#cli

,

#terminal

The whole point of development is solving problems. But very often we Developers...

Nov 3, 2021

CSS Logical Properties

#css

,

#html

CSS logical properties are properties which are used to design element on the...

Oct 5, 2021

Fluid Typography in CSS 💧

#css

,

#html

,

#typography

CSS Best Practices in Fluid Typography

Aug 15, 2021

CSS Units in a Nutshell 🐚

#css

,

#html

Are you still writing your css units in pixels and percentages? if you are then...

Aug 8, 2021

Master Markdown in 5minutes ⌚

#markdown

,

#documentation

Markdown is a lightweight markup language for creating formatted text using a...

Aug 1, 2021

What is JAMStack ✨

#jamstack

Jamstack stands for Javascript APIS and Markup and it is based on this idea of...

Jul 31, 2021

+

Check my latest Blog Post

This One HTML Attribute Could Save Your Web App from a Security Nightmare

Read Now
Oh My Gawwdd!!!!!!!

Wow you have been viewing my site since 20 seconds!

+
+