<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/automate-branch-cleanup-and-push-notifications-with-gitlab-tfafdqfjv" -->

---
title: Automate Branch Cleanup And Push Notifications With GitLab
description: GitLab's REST API lets you automate branch housekeeping and push notifications instead of doing them by hand. You can list, create and delete branches,...
canonical: https://daily.dev/posts/automate-branch-cleanup-and-push-notifications-with-gitlab-tfafdqfjv
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Automate Branch Cleanup And Push Notifications With GitLab | daily.dev
og:description: GitLab's REST API lets you automate branch housekeeping and push notifications instead of doing them by hand. You can list, create and delete branches,...
og:url: https://daily.dev/posts/automate-branch-cleanup-and-push-notifications-with-gitlab-tfafdqfjv
og:image: https://api.daily.dev/og/posts/TFafdqfJv.png
og:image:alt: Automate Branch Cleanup And Push Notifications With GitLab
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Automate Branch Cleanup And Push Notifications With GitLab

**[API Evangelist](https://daily.dev/sources/apievangelist)** · 4 min read · 0 upvotes · 0 comments

## Summary

GitLab's REST API lets you automate branch housekeeping and push notifications instead of doing them by hand. You can list, create and delete branches, including a single call that deletes every already-merged branch in a project. Webhook endpoints let your server hear about every push by adding, listing, updating or removing hooks. APIs.io catalogs 24 GitLab workflows built on these calls, such as 'Clean Up a Merged Branch' and 'Create and Protect a Release Branch'. The suggested starting point is running merged-branch cleanup on your busiest project.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://apievangelist.com/2026/10/29/automate-branch-cleanup-and-push-notifications-with-gitlab>

## Questions this post answers

### How do I delete all branches in a GitLab project that have already been merged?

Send a DELETE request to /api/v4/projects/{id}/repository/merged_branches, which removes every branch in the project that has already been merged. This is faster than deleting branches one at a time with DELETE /api/v4/projects/{id}/repository/branches/{branch} and is recommended as a safe first automation to run on your busiest project.

_Automating repo hygiene with GitLab's API is easier to track with daily.dev alongside other DevOps workflow tips._

### How do I get notified whenever someone pushes to a GitLab project?

Add a webhook with POST /projects/{id}/hooks so GitLab sends a message to your server whenever a push event happens. You can list existing hooks with GET /projects/{id}/hooks, check which events one is subscribed to with GET /projects/{id}/hooks/{hook_id}, change its delivery URL with PUT, or remove it with DELETE.

_Wiring up GitLab webhooks for team notifications is the kind of workflow worth bookmarking on daily.dev._

## Similar posts on daily.dev

- [Monitor, manage, and automate AI workflows](https://daily.dev/posts/monitor-manage-and-automate-ai-workflows-gmx0tuh7z) · GitLab · 0 upvotes · 0 comments
- [Merge queue APIs now available in Bitbucket Cloud](https://daily.dev/posts/merge-queue-apis-now-available-in-bitbucket-cloud-zwqwju2if) · Atlassian · 0 upvotes · 0 comments
- [GitHub Stacked PRs](https://daily.dev/posts/github-stacked-prs-ekt9rnyqu) · Hacker News · 2 upvotes · 0 comments
- [A Better Way to Prune Git Branches: fzf and a Tiny Loop](https://daily.dev/posts/a-better-way-to-prune-git-branches-fzf-and-a-tiny-loop-wruwytdqv) · Atomic Spin · 2 upvotes · 0 comments

---

Tags: [#cicd](https://daily.dev/tags/cicd), [#gitlab](https://daily.dev/tags/gitlab)

[View this post on daily.dev](https://daily.dev/posts/automate-branch-cleanup-and-push-notifications-with-gitlab-tfafdqfjv)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Automate Branch Cleanup And Push Notifications With GitLab","url":"https://daily.dev/posts/automate-branch-cleanup-and-push-notifications-with-gitlab-tfafdqfjv","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/automate-branch-cleanup-and-push-notifications-with-gitlab-tfafdqfjv"},"datePublished":"2026-10-29T18:24:33.273Z","dateModified":"2026-10-29T18:24:57.342Z","description":"GitLab's REST API lets you automate branch housekeeping and push notifications instead of doing them by hand. You can list, create and delete branches,...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/db01c402c28a7c3cf8739ea7c0fbc404?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/db01c402c28a7c3cf8739ea7c0fbc404?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"API Evangelist","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"API Evangelist","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/a36244ae67bc4f41a605f780267ecb5f","url":"https://daily.dev/sources/apievangelist"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/automate-branch-cleanup-and-push-notifications-with-gitlab-tfafdqfjv","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"cicd,gitlab","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"API Evangelist","item":"https://daily.dev/sources/apievangelist"},{"@type":"ListItem","position":3,"name":"Automate Branch Cleanup And Push Notifications With GitLab"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/automate-branch-cleanup-and-push-notifications-with-gitlab-tfafdqfjv#faq","mainEntity":[{"@type":"Question","name":"How do I delete all branches in a GitLab project that have already been merged?","acceptedAnswer":{"@type":"Answer","text":"Send a DELETE request to /api/v4/projects/{id}/repository/merged_branches, which removes every branch in the project that has already been merged. This is faster than deleting branches one at a time with DELETE /api/v4/projects/{id}/repository/branches/{branch} and is recommended as a safe first automation to run on your busiest project. Automating repo hygiene with GitLab's API is easier to track with daily.dev alongside other DevOps workflow tips."}},{"@type":"Question","name":"How do I get notified whenever someone pushes to a GitLab project?","acceptedAnswer":{"@type":"Answer","text":"Add a webhook with POST /projects/{id}/hooks so GitLab sends a message to your server whenever a push event happens. You can list existing hooks with GET /projects/{id}/hooks, check which events one is subscribed to with GET /projects/{id}/hooks/{hook_id}, change its delivery URL with PUT, or remove it with DELETE. Wiring up GitLab webhooks for team notifications is the kind of workflow worth bookmarking on daily.dev."}}]}
```

