diff --git a/controllers/gitrepository_controller.go b/controllers/gitrepository_controller.go index 77deb35a8..b8179af00 100644 --- a/controllers/gitrepository_controller.go +++ b/controllers/gitrepository_controller.go @@ -321,7 +321,7 @@ func (r *GitRepositoryReconciler) sync(ctx context.Context, repository sourcev1. if revision == "" { revision = fmt.Sprintf("%s/%s", branch, ref.Hash().String()) - if repository.Spec.Reference.Tag != "" { + if repository.Spec.Reference != nil && repository.Spec.Reference.Tag != "" { revision = fmt.Sprintf("%s/%s", repository.Spec.Reference.Tag, ref.Hash().String()) } }