← 返回首页
python-gitlab/docs/gl_objects/branches.rst at feat/graphql · python-gitlab/python-gitlab · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Latest commit

 

History

History
42 lines (26 loc) · 848 Bytes
 feat/graphql
Top

File metadata and controls

  • Preview
  • Code
  • Blame
42 lines (26 loc) · 848 Bytes

Branches

References

Examples

Get the list of branches for a repository:

branches = project.branches.list()

Get a single repository branch:

branch = project.branches.get('main')

Create a repository branch:

branch = project.branches.create({'branch': 'feature1', 'ref': 'main'})

Delete a repository branch:

project.branches.delete('feature1') # or branch.delete()

Delete the merged branches for a project:

project.delete_merged_branches()

To manage protected branches, see :doc:`/gl_objects/protected_branches`.

Footer

© 2026 GitHub, Inc.