Skip to content

Commit

Permalink
clone single branch with depth of 1
Browse files Browse the repository at this point in the history
cloning only the default branch and with a depth of 1 speeds up the clone time greatly

```sh
I0818 19:01:24.786890   27900 git.go:79] Going to run git clone --depth=1 --single-branch -v git@gitlab.com:test/test.git /Users/dbrian/.krew/index/test
Cloning into '/Users/dbrian/.krew/index/test'...
I0818 19:01:25.342370   27900 fetch_tag.go:47] Parsing response from GitHub
```

```sh
I0818 19:00:39.064036   27722 git.go:79] Going to run git clone -v git@gitlab.com:test/test.git /Users/dbrian/.krew/index/test
Cloning into '/Users/dbrian/.krew/index/test'...
I0818 19:00:48.527775   27722 root.go:180] Upgrade check was skipped or has not finished
```

Signed-off-by: Brian Davis <dbrian@vmware.com>
  • Loading branch information
slimm609 committed Aug 18, 2023
1 parent d2e660d commit bbf17d4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/gitutil/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func EnsureCloned(uri, destinationPath string) error {
if ok, err := IsGitCloned(destinationPath); err != nil {
return err
} else if !ok {
_, err = Exec("", "clone", "-v", uri, destinationPath)
_, err = Exec("", "clone", "--depth=1", "--single-branch", "-v", uri, destinationPath)
return err
}
return nil
Expand Down

0 comments on commit bbf17d4

Please sign in to comment.