Skip to content

Commit

Permalink
chore: added possibility to specify maxBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
nemisj committed Aug 15, 2024
1 parent e6fab8d commit 1d08735
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 177 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v7.10.1
v16.19.0
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ List or remove local tracked branches, which are deleted from the remote.

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.

## What does it do
## What does it do?

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.

Expand All @@ -19,19 +19,18 @@ This command works without the need to run `git fetch -p`, but a working network
$ npm install -g git-removed-branches
```

Please install a package globally with -g flag so that you can use it directly as a subcommand of git, like this:
Please install a package globally with -g flag so that you can use it directly as a sub command of git, like this:

```bash
$ git removed-branches
```

### Python
### NPX

It's also possible to use python instead of node.js/npm package.
Download **git-removed-branches.py** script, remove the extension and place it inside your $PATH variable so that you can use it directly as a subcommand of git:
It's also possible to use package through npx directly. Execute inside any git folder:

```bash
$ git removed-branches
$ npx git-removed-branches
```

## Usage
Expand All @@ -43,6 +42,8 @@ $ git removed-branches
This command will look through the branches that are no longer available on the remote and display them.
In case you haven't run `git fetch -p`, it will warn you to do so.

This command is safe to run and it will not alter your repository.


### Removing

Expand All @@ -52,6 +53,8 @@ To delete local branches use `--prune` or `-p` flag
$ git removed-branches --prune
```

This command will compare your local branches to the remote ones and remove, those which do not exist anymore on the remote side.

### Different remote

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:
Expand All @@ -73,3 +76,14 @@ you can force deletion by using `--force` flag or use `-f` alias
```bash
$ git removed-branches --prune --force
```

## Troubleshooting:


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/nemisj/git-removed-branches/issues/11) )

You can fix this, by specifying NODE_MAX_BUFFER environment variable, like:

```
NODE_MAX_BUFFER=1048576 git removed-branches
```
169 changes: 0 additions & 169 deletions git-removed-branches.py

This file was deleted.

3 changes: 2 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const child_process = require('child_process');

const maxBuffer = 'NODE_MAX_BUFFER' in process.env ? Number(process.env.NODE_MAX_BUFFER): undefined;
const exec = (argsArray, skipError) => {
return new Promise((resolve, reject) => {
child_process.exec(argsArray.join(' '), (err, stdout, stderr) => {
child_process.exec(argsArray.join(' '), { maxBuffer }, (err, stdout, stderr) => {
if (err) {
if (skipError) {
return resolve({ stdout, stderr });
Expand Down

0 comments on commit 1d08735

Please sign in to comment.