- v4 API:
- v3 API:
- GitLab API: https://docs.gitlab.com/ce/api/branches.html
Get the list of branches for a repository:
.. literalinclude:: branches.py :start-after: # list :end-before: # end list
Get a single repository branch:
.. literalinclude:: branches.py :start-after: # get :end-before: # end get
Create a repository branch:
.. literalinclude:: branches.py :start-after: # create :end-before: # end create
Delete a repository branch:
.. literalinclude:: branches.py :start-after: # delete :end-before: # end delete
Protect/unprotect a repository branch:
.. literalinclude:: branches.py :start-after: # protect :end-before: # end protect
Note
By default, developers are not authorized to push or merge into protected
branches. This can be changed by passing developers_can_push or
developers_can_merge:
branch.protect(developers_can_push=True, developers_can_merge=True)