<@ULVA73B9P> can one use a git tag instead of bran...
# ask-marvin
a
@Marvin can one use a git tag instead of branch in a deployment?
m
thought for 102.1 seconds
Yes — in Prefect 3.x you can use a git tag anywhere Prefect asks for the repo `branch`/ref. For example:
Copy code
python
from prefect import flow
from prefect.runner.storage import GitRepository

@flow
def my_flow():
    pass

if __name__ == "__main__":
    my_flow.from_source(
        source=GitRepository(
            url="<https://github.com/my-org/my-repo.git>",
            branch="v1.2.3",  # tag name
        ),
        entrypoint="flows.py:my_flow",
    ).deploy(
        name="prod",
        work_pool_name="my-pool",
    )
Or in `prefect.yaml`:
Copy code
yaml
pull:
  - prefect.deployments.steps.git_clone:
      repository: <https://github.com/my-org/my-repo.git>
      branch: v1.2.3
A few notes: - Prefect uses the
branch
field for both branches and tags - You cannot set both
branch
and
commit_sha
at the same time - If omitted, Prefect defaults to
main
Relevant docs: - Store flow code - Deploy via Python If you want, I can also show the exact syntax for doing this with
prefect deploy
from a
prefect.yaml
.