pcreux/git-branch-delete-orphans — pull request #7 by pvdb (2013-04-16 11:03:59+00:00)
Title: Run "git branch-delete-orphans" at top level of git repo

Hey @pcreux, it's been a while since my last pull request, so I thought I'd send you this! :smile:

This pull request fixes two issues that I recently encountered when using the gem.

**running the script outside a git repo**

This would result in output similar to:

```shell
cat: .git/config: No such file or directory
Listing remote branches...
fatal: No remote configured to list refs from.

No orphaned local branches, nothing to do.
```

It now detects this situation, and prints out an error message instead of trying to proceed.

**running the script in a subdirectory of a git repo**

_(instead of running it at the top level of the repo, which is what you'd usually do)_

This would result in output similar to:

```shell
cat: .git/config: No such file or directory
Listing remote branches...
From /Users/pvandenb/Repositories/gitroot/github.git/

No orphaned local branches, nothing to do.
```

It now detects this situation, and _(temporarily)_ changes the working directory to the top level of the git repo.