> For the complete documentation index, see [llms.txt](https://smallso.gitbook.io/tencent-cloud-sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://smallso.gitbook.io/tencent-cloud-sdk/python-docs/serverless-functions/class-and-method/function-code/use-git-repository.md).

# use\_git\_repository 方法

## 简要

配置使用给定 Git 仓库作为无服务器云函数源代码来源。

```python
def use_git_repository(self,
    git_url: str,
    git_branch_name: str = None,
    git_directory_name: str = None,
    git_commit_id: str = None,
    git_username: str = None,
    git_password: str = None
)
```

## 参数

该方法具有以下参数，其参数、参数类型和参数描述如下：

| 参数                   | 类型  | 必选 | 描述                           |
| -------------------- | --- | -- | ---------------------------- |
| git\_url             | str | 是  | Git 仓库 URL 字符串。              |
| git\_branch\_name    | str | 否  | Git 仓库中已创建的分支名称。             |
| git\_directory\_name | str | 否  | Git 仓库中包含用于无服务器云函数源代码的目录名称。  |
| git\_commit\_id      | str | 否  | Git 仓库中包含用于无服务器云函数源代码的提交 ID。 |
| git\_username        | str | 否  | 拥有给定 Git 仓库访问权限的用户名。         |
| git\_password        | str | 否  | 拥有给定 Git 仓库访问权限用户的密码。        |

## 返回值

该方法返回当前代表无服务器云函数源代码配置的 [FunctionCode](https://smallso.gitbook.io/tencent-cloud-sdk/python-docs/serverless-functions/class-and-method/function-code) 类实例本身。

## 异常

该方法可能会主动引发的异常类型如下：

#### ValueError

参数值或类型不符合预期。

## 示例

下面我们将通过一段 Python 代码向您演示如何使用该方法：

```python
functions.FunctionCode.use_git_repository(
    git_url = 'https://github.com/tencentyun/scf-demo-repo.git',
    git_directory_name = 'Python3.6-helloworld'
)
```

## 适用于

#### Tencent Cloud SDK for Python

产品软件包：tencent-cloud-sdk-serverless-functions >= 0.1.1
