davidraviv / gh-clean-branches

Safely deletes local branches with no upstream and no un-pushed commits
MIT License
177 stars 15 forks source link

Multiple remotes messes things up #11

Closed omegahm closed 2 years ago

omegahm commented 3 years ago

Describe the bug I have a repository with multiple remotes (here: origin and production). Doing a gh clean-branches --dry-run I get

Sync branches
fatal: 'origin
production' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Checking out
Your branch is up to date with 'origin/master'.
Pulling
fatal: 'origin
production' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Failed pull, Check for uncomited changes.

To Reproduce Steps to reproduce the behavior:

  1. Have a repository with multiple remotes
  2. Run gh clean-branches --dry-run
  3. See error
davidraviv commented 3 years ago

Thanks, @omegahm. Currently, the script uses this git command to fetch the upstream name:

git remote show

Do you know a way to fetch the correct remote when there are multiple ones? It will allow a quick fix. What is the response for the above command in your repo?

omegahm commented 3 years ago

As I have two remotes, it shows both of them each on their own line:

$ git remote show
origin
production
davidraviv commented 2 years ago

I added a validation to prevent the script from crashing in v0.7.1.

davidraviv commented 2 years ago

Currently, I lack the resources to support multiple upstream.

Anyone in need of this feature, please do upvote this issue, or even better, contribute a PR.

chrisgoffinet commented 2 years ago

@omegahm @davidraviv mind checking out this PR? Looks like its working correctly for me with these changes.

davidraviv commented 2 years ago

Thanks, @chrisgoffinet for the effort! I'll take a look at the PR. @omegahm I'll appreciate it if you can confirm that this PR works on your multi remotes repo.

davidraviv commented 2 years ago

@omegahm A new version that supports multiple upstream is not available. @chrisgoffinet Thanks for the effort in trying to improve the extension!

I hope you'll find the new version helpful. Cheers 🍻