<@ULVA73B9P> How to checkout flow code in GitHub f...
# ask-community
e
@Marvin How to checkout flow code in GitHub from a branch
m
To help you with checking out flow code from a branch in Prefect, it's important to know which version of Prefect you are using, as the process may differ between Prefect 2.x and 3.x. Could you please confirm your Prefect version?
e
@Marvin How to checkout flow code in GitHub from a branch using Prefect 2
m
In Prefect 2.x, to checkout flow code from a GitHub branch, you can use the
GitRepository
feature: 1. Using `from_source`: You should specify your GitHub repository and the entry point for your flow code. Here is a sample of how you can do it:
Copy code
python
   from prefect import flow
   from prefect_github import GitHubCredentials
   from prefect_github import GitRepository

   if __name__ == "__main__":
       flow.from_source(
           source=GitRepository(
               url="<https://github.com/org/private-repo.git>",
               credentials=GitHubCredentials.load("my-github-credentials-block"),
               branch="your-branch-name"  # optional: specify the branch here
           ),
           entrypoint="my_file.py:my_flow"  # Specify your flow's entrypoint
       ).deploy(
           name="private-github-deploy",
           work_pool_name="my_pool",
           build=False
       )
2. Using `prefect.yaml`: When creating a deployment, the reference to the GitHub credentials block can be added as shown below:
Copy code
yaml
   pull:
     - prefect.deployments.steps.git_clone:
         repository: <https://github.com/org/repo.git>
         branch: your-branch-name  # optional: specify the branch here
         credentials: "{{ prefect.blocks.github-credentials.my-github-credentials-block }}"
This allows you to sync your flow code from a specific branch in your GitHub repository. For more detailed instructions, you can refer to the Prefect GitHub Integration documentation. Let me know if you have further questions!