diff --git a/commands/command_clone.go b/commands/command_clone.go index 0bf1ca71..aff4c54f 100644 --- a/commands/command_clone.go +++ b/commands/command_clone.go @@ -85,17 +85,21 @@ func cloneCommand(cmd *cobra.Command, args []string) { remote = "origin" } - includeArg, excludeArg := getIncludeExcludeArgs(cmd) - filter := buildFilepathFilter(cfg, includeArg, excludeArg) - if cloneFlags.NoCheckout || cloneFlags.Bare { - // If --no-checkout or --bare then we shouldn't check out, just fetch instead - cfg.CurrentRemote = remote - fetchRef("HEAD", filter) - } else { - pull(remote, filter) - err := postCloneSubmodules(args) - if err != nil { - Exit("Error performing 'git lfs pull' for submodules: %v", err) + ref, err := git.CurrentRef() + + if ref != nil { + includeArg, excludeArg := getIncludeExcludeArgs(cmd) + filter := buildFilepathFilter(cfg, includeArg, excludeArg) + if cloneFlags.NoCheckout || cloneFlags.Bare { + // If --no-checkout or --bare then we shouldn't check out, just fetch instead + cfg.CurrentRemote = remote + fetchRef("HEAD", filter) + } else { + pull(remote, filter) + err := postCloneSubmodules(args) + if err != nil { + Exit("Error performing 'git lfs pull' for submodules: %v", err) + } } }