Published at
Updated at
Reading time
2min
This post is part of my Today I learned series in which I share all my web development learnings.

I browsed electron boilerplates today and I discovered something interesting in the electron-react-boilerplate.

The getting started guide includes advises to use git clone --depth=1.

git clone --depth=1 https://github.com/chentsulin/electron-react-boilerplate.git your-project-name

What's this depth argument? Let's find out!

$  git clone --depth=1 https://github.com/chentsulin/electron-react-boilerplate.git your-project-name
Cloning into 'your-project-name'...

$ cd your-project-name

$ git log

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

Look at the entries shown in the git log. Thanks to the --depth=1 argument the just cloned repository only includes a single commit. You might know that cloning an active project can take some moments because you're downloading the entire history.

But thanks to --depth getting the source code was super speedy!

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 checking out a project.

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

How to download GitHub projects without using git

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.

# Download chentsulin/electron-react-boilerplate without
# history or .git directory
$ npm init using chentsulin/electron-react-boilerplate

npm init using uses the degit package under the hood. You can use that one, too, if you like.

# Download chentsulin/electron-react-boilerplate without
# history or .git directory
$ degit chentsulin/electron-react-boilerplate

Happy downloading!

If you enjoyed this article...

Join 5.5k readers and learn something new every week with Web Weekly.

Web Weekly — Your friendly Web Dev newsletter
Reply to this post and share your thoughts via good old email.
Stefan standing in the park in front of a green background

About Stefan Judis

Frontend nerd with over ten years of experience, freelance dev, "Today I Learned" blogger, conference speaker, and Open Source maintainer.

Related Topics

Related Articles