Akram Gharbi
11/19/2025, 4:53 PM- prefect.deployments.steps.git_clone:
repository: <https://github.com/PrefectHQ/prefect.git>
branch: my-branchMarvin
11/19/2025, 4:53 PMMarvin
11/19/2025, 4:58 PMprefect.deployments.steps.git_clone step does not expose a parameter to control the checkout folder name. It will create <repo> or <repo>-<branch> (slashes in branches are replaced with -). So you can’t rename it via a step argument.
Your options:
- Most common fix: set the working directory to the cloned repo so imports resolve correctly
pull:
- prefect.deployments.steps.git_clone:
id: repo
repository: <https://github.com/PrefectHQ/prefect.git>
branch: my-branch
- prefect.deployments.steps.set_working_directory:
directory: "{{ repo.directory }}"
This avoids relying on the outer folder name. If your package lives at the repo root (e.g., repo_name/), import repo_name will work once the working dir is set.
- Rename the folder after clone (if you truly need a specific name)
pull:
- prefect.deployments.steps.git_clone:
id: repo
repository: <https://github.com/PrefectHQ/prefect.git>
branch: my-branch
- prefect.deployments.steps.run_shell_script:
script: |
mv "{{ repo.directory }}" "prefect"
- prefect.deployments.steps.set_working_directory:
directory: ./prefect
- Bypass git_clone and clone to a chosen directory yourself
pull:
- prefect.deployments.steps.run_shell_script:
script: |
git clone --branch my-branch <https://github.com/PrefectHQ/prefect.git> prefect
- prefect.deployments.steps.set_working_directory:
directory: ./prefect
If you need auth for a private repo, you can inject a token via env variables or a Secret block.
- If you deploy via Python, you can control the folder name using GitRepository(name=...)
from prefect import flow
from prefect.runner.storage import GitRepository
flow.from_source(
GitRepository(
url="<https://github.com/PrefectHQ/prefect.git>",
branch="my-branch",
name="prefect", # desired checkout directory
),
entrypoint="path/to/flow.py:my_flow",
).deploy(
name="my-deployment",
work_pool_name="my-pool",
)
Docs:
- git_clone and set_working_directory
- run_shell_script
Quick question to ensure the best path: are your imports failing because the Python package directory differs from the repo root name, or because you’re constructing paths that include the literal repo folder name? If it’s the latter, pointing set_working_directory at {{ repo.directory }} is usually the simplest fix.Akram Gharbi
11/19/2025, 5:07 PMpull:
- prefect.deployments.steps.run_shell_script:
script: |
git clone --branch my-branch <https://github.com/PrefectHQ/prefect.git> prefect
- prefect.deployments.steps.set_working_directory:
directory: ./prefect
and how to include the access token in the git command there ?Nate
11/19/2025, 5:46 PM