Instead of repeating these three lines four times, make it into a method:

```ruby
def branches_cmd(location)
   git_part = location == 'origin' ? ... : ...
   "#{git_part}
    grep -v master |
    grep -v stable |
    grep -v #{currentBranch} "
end
```