Google Sheets iconSwift icon
Published at
Updated at
Reading time

This post is part of my Today I learned series in which I share all my learnings regarding web development.

I was browsing electron boilerplates today, and inside of the electron-react-boilerplate I found something interesting. The getting started guide include a git clone --depth=1.

git clone --depth=1 your-project-name

What's that? I tried it immediately.

/tmp 😩  🐿  😪
▶ git clone --depth=1 your-project-name
Cloning into 'your-project-name'...

/tmp 😋  😦  🐍
▶ cd your-project-name

/tmp/your-project-name 😏  😝  😷   master ヾ(⌐■_■)ノ
▶ git lg

* 586b84f Amila Welihinda -  (grafted, HEAD -> master, origin/master, origin/HEAD) Misc code style changes to menu.js (5 weeks ago)

git's documentation defines the depth argument as follows:

Create a shallow clone with a history truncated to the specified number of commits.

Use depth to define that you don't want to clone and include thousands of unrelated commits from the past when cloning a boilerplate project. Limiting and truncating the history is valuable for projects such as electron-react-boilerplate.

Ideally, there would be a way to use git to clone projects without the .git directory. Unfortunately, I don't think you can do that with git, though. (if you know how to do it, please let me know)

But – if you have a recent version of npm installed on your machine, I recently discovered an intuitive command to download GitHub projects without history and git directory. The command npm init using is easy to remember and downloads history-free projects. Read more about it in my discovery post.

Related Topics

Related Articles