From 406cd29676bcb53a4538d0407fd279afa98737c9 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Wed, 10 Mar 2021 15:43:55 -0600 Subject: [PATCH] Add Clone A Repo Just For The Files, Without History as a git til --- README.md | 3 ++- ...-repo-just-for-the-files-without-history.md | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 git/clone-a-repo-just-for-the-files-without-history.md diff --git a/README.md b/README.md index 8bfbb4f..26413e0 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud). -_1080 TILs and counting..._ +_1081 TILs and counting..._ --- @@ -227,6 +227,7 @@ _1080 TILs and counting..._ - [Cherry Pick A Range Of Commits](git/cherry-pick-a-range-of-commits.md) - [Clean Out All Local Branches](git/clean-out-all-local-branches.md) - [Clean Up Old Remote Tracking References](git/clean-up-old-remote-tracking-references.md) +- [Clone A Repo Just For The Files, Without History](git/clone-a-repo-just-for-the-files-without-history.md) - [Clone A Repo Locally From .git](git/clone-a-repo-locally-from-git.md) - [Configure Global gitignore File](git/configure-global-gitignore-file.md) - [Configuring The Pager](git/configuring-the-pager.md) diff --git a/git/clone-a-repo-just-for-the-files-without-history.md b/git/clone-a-repo-just-for-the-files-without-history.md new file mode 100644 index 0000000..3957900 --- /dev/null +++ b/git/clone-a-repo-just-for-the-files-without-history.md @@ -0,0 +1,18 @@ +# Clone A Repo Just For The Files, Without History + +Though the history of a Git repository is a huge part of its value, sometimes +you just want a copy of the files for the current state of the main branch. + +Using the `--depth` flag with `git-clone` allows you to clone a repo without +its history. You can do that with a depth of `1` which will clone the top of +the tree and exclude all the past history. + +```bash +$ git clone --depth 1 git@github.com:jbranchaud/til.git +``` + +If you do a `git log` after this, you'll see there is only one commit in the +history. Depending on the size and history of the repo, you may notice that the +clone is quicker than one that includes the full history. + +See `man git-clone` for more details.