You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
+
9
+
---
10
+
11
+
Copyright for portions of project "git-branch-cleanup" are held by Maks Nemisj as part of project "git-removed-branches". All other copyright for project "git-branch-cleanup" are held by Craig Patik.
-[Remove tracking branches no longer on remote](https://stackoverflow.com/questions/7726949/remove-tracking-branches-no-longer-on-remote)
10
10
-[How to prune local tracking branches that do not exist on remote anymore?](https://stackoverflow.com/questions/13064613/how-to-prune-local-tracking-branches-that-do-not-exist-on-remote-anymore/30494276#30494276)
Because I'm tired of doing every time `git fetch -p`, `git branch -r`, `git branch` and keep comparing which branches are gone from the GitHub, but still available locally and doing `git branch -D ${branch_name}` on one by one of them.
16
+
Because I'm tired of doing every time `git fetch -p`, `git branch -r`, `git branch` and keep comparing which branches are gone from the GitHub, but still available locally and doing `git branch -D ${branch_name}` on each of them, one by one.
18
17
19
18
## What does it do?
20
19
21
-
This command will compare your local branches with remote and show you branches that are no longer available on remote but are still presented in your local repository. You can use it to view and delete all (remotely) removed branches in one go using `--prune` flag.
20
+
This command will compare your local branches with remote and show you branches that are no longer available on remote but are still presented in your local repository. You can use it to view and delete all (remotely) removed branches in one go using `--prune-all` flag.
22
21
23
22
This command works without the need to run `git fetch -p`, but a working network connection to your remote is required. If no connection can be established with the remote repository, then local information about your remote will be used instead. If your local repository is not in sync with the remote repository, it will warn you about it.
24
23
@@ -27,50 +26,52 @@ This command works without the need to run `git fetch -p`, but a working network
27
26
### NPM
28
27
29
28
```bash
30
-
$ npm install -g git-removed-branches
29
+
npm install -g git-branch-cleanup
31
30
```
32
31
33
32
Please install a package globally with -g flag so that you can use it directly as a sub command of git, like this:
34
33
35
34
```bash
36
-
$ git removed-branches
35
+
git branch-cleanup
37
36
```
38
37
39
38
### NPX
40
39
41
-
It's also possible to use package through npx directly. Execute inside any git folder:
40
+
It's also possible to use package through `npx` without installing:
42
41
43
42
```bash
44
-
$ npx git-removed-branches
43
+
npx git-branch-cleanup
45
44
```
46
45
47
46
## Usage
48
47
49
48
```bash
50
-
$ git removed-branches
49
+
git branch-cleanup
51
50
```
52
51
53
52
This command will look through the branches that are no longer available on the remote and display them.
54
53
In case you haven't run `git fetch -p`, it will warn you to do so.
55
54
56
-
This command is safe to run and it will not alter your repository.
55
+
<imgwidth="609"alt="Prompt with list of branches, allowing arbitrary selection"src="https://github.com/user-attachments/assets/6a0530a7-c13c-42da-a983-ab365dd51f74" />
To delete local branches use `--prune` or `-p` flag
61
+
To delete all local branches without choosing which ones, and without confirmation, use `--prune-all` or `-p` flag
61
62
62
63
```bash
63
-
$ git removed-branches --prune
64
+
git branch-cleanup --prune-all
64
65
```
65
66
66
67
This command will compare your local branches to the remote ones and remove, those which do not exist anymore on the remote side.
67
68
68
-
### Different remote
69
+
### Custom remote
69
70
70
71
If you have configured remote alias to something different than **'origin'**, you can use `--remote` or `-r` flag to specify the name of the remote. e.g., to specify remote to be `upstream`, you can use:
71
72
72
73
```bash
73
-
$ git removed-branches --remote upstream
74
+
git branch-cleanup --remote upstream
74
75
```
75
76
76
77
## Forcing removal
@@ -84,27 +85,27 @@ The branch {branch_name} is not fully merged.
84
85
you can force deletion by using `--force` flag or use `-f` alias
85
86
86
87
```bash
87
-
$ git removed-branches --prune --force
88
+
git branch-cleanup --prune-all --force
88
89
```
89
90
90
91
## Version
91
92
92
-
To find out, which version you use ( since 2.3.0 )
93
+
To print the version:
93
94
94
-
```
95
-
git removed-branches --version
95
+
```bash
96
+
git branch-cleanup --version
96
97
```
97
98
98
99
## Troubleshooting:
99
100
100
-
If you encounter error `ERR_CHILD_PROCESS_STDIO_MAXBUFFER` it is possible that your repository contains too much branches, more then 3382. ( see [discussion](https://github.com/patik/git-removed-branches/issues/11) )
101
+
If you encounter error `ERR_CHILD_PROCESS_STDIO_MAXBUFFER` it is possible that your repository contains too many branches (more then 3382—see [discussion](https://github.com/patik/git-branch-cleanup/issues/11)).
101
102
102
-
You can fix this, by specifying NODE_MAX_BUFFER environment variable, like:
103
+
You can fix this by specifying NODE_MAX_BUFFER environment variable. For example:
103
104
104
-
```
105
-
NODE_MAX_BUFFER=1048576 git removed-branches
105
+
```bash
106
+
NODE_MAX_BUFFER=1048576 git branch-cleanup
106
107
```
107
108
108
109
## Credit
109
110
110
-
Forked from [git-removed-branches](https://github.com/nemisj/git-removed-branches) by [Maks Nemisj](https://github.com/nemisj)@nemisj
111
+
Forked from [git-branch-cleanup](https://github.com/nemisj/git-branch-cleanup) by [Maks Nemisj](https://github.com/nemisj)@nemisj
0 commit comments