Ahmad Awais

NAVIGATE


SHARE


Shallow Clone a Large Git Repository Quickly

Ahmad AwaisAhmad Awais

Say you have a large git repository say 1 GB or even bigger. It may have a lot of branches and a long history. You now want to clone it to make some changes and create a pull request. Cloning it in its entirety with git clone would be a bad idea. Instead, do this:

git clone -b <branch> <url> --depth=1

A practical example would be:

git clone -b master https://github.com/gatsbyjs/gatsby --depth=1

The giant 735.03 MB Gatsby repository, cloned this way is about 680 MB in size. I read that Jira is 677MB, with the working directory being another 320MB, when you clone this way.

Explanation:#

You can work this magic when pulling down the code as well:

git pull --rebase origin <branch> --depth=1

A practical example would be:

git pull --rebase origin master --depth=1

That’s about it. You are now shallow cloning and pulling your git repo. It doesn’t make that huge of an impact but I like to stay minimal as far as I can.

Use your code for good.

Founder & CEO at Langbase.com — The Composable AI Developer platform · Serverless AI Cloud · Ship agentic AI pipes, tools, and memory with BaseAI — The first Web AI Framework (free, open-source, local-first, deploys serverless, agentic pipes, tools, and memory)

Ex VP DevTools & DevRel Eng. Rapid · Google Developers Advisory Board (gDAB) founding member. 🧑‍💻 AI/ML/DevTools Angel InvestorAI/ML Advisory Board San Francisco, DevNetwork

🎩 Award-winning Open Source Engineer & Dev Advocate 🦊 Google Developers Expert Web DevRel 🚀 NASA Mars Ingenuity Helicopter mission code contributor 🏆 8th GitHub Stars Award recipient with 5x GitHub Stars Award (Listed as GitHub's #1 JavaScript trending developer).

🌳 Node.js foundation Community Committee Outreach Lead, Member Linux Foundation, OpenAPI Business Governing Board, and DigitalOcean Navigator. 📟 Teaching thousands of developers Node.js CLI Automation and VSCode.pro course. Over 142 million views, 24 yrs Blogging, 108K developers learning, 200+ FOSS.

✌️ Author of various open-source dev-tools and software libraries utilized by millions of developers worldwide WordPress Core Developer 📣 TEDx Speaker with 100+ international talks.

As quoted by: Satya Nadella · CEO of Microsoft — Awais is an awesome example for developers.
💜 Loves his wife (Maedah) ❯ Read more about Ahmad Awais.

👋… Awais is mostly active on 𝕏 @MrAhmadAwais

📨

Developers Takeaway

Stay ahead in the web dev community with Ahmad's expert insights on open-source, developer relations, dev-tools, and side-hustles. Insider-email-only-content. Don't miss out - subscirbe for a dose of professional advice and a dash of humor. No spam, pinky-promise!

✨ 172,438 Developers Already Subscribed
Comments 0
There are currently no comments.