Urgent.News

What's breaking now, across thousands of outlets.

Tech

Cómo borrar ramas de git ya fusionadas sin miedo (script Bash con dry-run)

Si llevas unos meses en un proyecto, seguramente git branch te devuelve una lista eterna: fix-login , feature/pagos , prueba-2 ... La mayoría ya se fusionaron hace tiempo, pero nadie se atreve a borrarlas por miedo a perder trabajo. En este tutorial vamos a construir un script pequeño que las limpia de forma segura. La idea clave: --merged Git ya sabe qué ramas están fusionadas. Una rama está…

Git branches can quickly pile up, especially in long-running projects. Many branches may have already merged, but concerns about losing work often prevent users from deleting them. This tutorial will walk you through a simple script that safely removes these merged branches.

The key idea is that git knows which branches have been merged into a specific branch. A branch is merged into the main branch when its last commit is reachable from the main branch. To remove a branch without losing any commits, you use git branch --merged followed by git for-each-ref.

The script first identifies branches that are merged into the specified base branch (main in this case). It then filters out any protected branches like main, develop, staging, production, and the branch you're currently on. The script avoids making changes by default; it either requires a dry-run or an explicit confirmation before deleting any branches. This ensures you never accidentally delete critical branches.

In case you're using Git's Squash and Merge or Rebase and Merge features on platforms like GitHub, which don't push original commits from merged pull requests into the main branch, you'll need to review these branches manually. The script doesn't handle these instances, but rather operates based on git's standard merging behavior.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

I built a 3D startup tycoon in a single HTML file (and open-sourced it)

Founder's Way is a 3D startup tycoon that runs in the browser. You start in a garage with your own business idea and try to grow it into a headquarters downtown under realistic costs, taxes and churn.

  • Founder's Way is a browser-based 3D startup simulator in a single HTML file
  • Game simulates business ideas with 12 key assumptions and validation tests
  • Open-source development allows community contributions and feedback

The Best Way to Sideload Games on Quest Just Got Better

SideQuestのニュースを見て、公式ストアの「今すぐ始められる」弱視VRトレーニングを試してみた SideQuestがダウンロード・セットアッププロセスを大幅に簡素化したというニュースをRoad to…

More from Wednesday 28 October →