2023-03-20 13:39:43 +00:00
|
|
|
---
|
|
|
|
categories:
|
|
|
|
- DevOps
|
|
|
|
tags: [git]
|
|
|
|
---
|
|
|
|
|
|
|
|
# Stale branches and pruning
|
|
|
|
|
2024-02-02 15:58:13 +00:00
|
|
|
A **stale branch** is a
|
|
|
|
[remote tracking branch](/DevOps/Git/Remote_tracking_branches.md) that **no
|
|
|
|
longer tracks anything** because the actual branch on the remote has been
|
|
|
|
deleted.
|
2023-03-20 13:39:43 +00:00
|
|
|
|
2024-02-02 15:58:13 +00:00
|
|
|
If _you_ delete the remote branch, the remote tracking branch will also be
|
|
|
|
deleted. However if a _collaborator_ deletes the remote branch, your remote
|
|
|
|
tracking branch will remain, becoming a stale branch.
|
2023-03-20 13:39:43 +00:00
|
|
|
|
2024-02-02 15:58:13 +00:00
|
|
|
In order to get rid of it, we need to manually remove it. We can do this with
|
|
|
|
the general `prune` command:
|
2023-03-20 13:39:43 +00:00
|
|
|
|
|
|
|
```sh
|
|
|
|
git remote prune origin
|
|
|
|
|
|
|
|
# or run a preview of the action
|
|
|
|
|
|
|
|
git remote prune origin --dry-run
|
|
|
|
```
|