
Git: Deletion of merged branches taken beyond shell hacks - spyc
https://github.com/hartwork/git-delete-merged-branches
======
chmaynard
Instead of re-packaging various git commands, I'd like to encourage people to
contribute their ideas and skills to the actual git project. Send an email to
git@vger.kernel.org, volunteer to help, and ask for advice and direction. Git
needs you!

~~~
RyJones
Maybe? We've had mentorships over the last couple of years trying to introduce
some crypto features to Git, and they've been rebuffed.

~~~
justincormack
What sort of features?

~~~
RyJones
git-dids.

2019:
[https://wiki.hyperledger.org/display/INTERN/Git+signing+with...](https://wiki.hyperledger.org/display/INTERN/Git+signing+with+DIDs)

2020:
[https://wiki.hyperledger.org/display/INTERN/Git+Commit+Signi...](https://wiki.hyperledger.org/display/INTERN/Git+Commit+Signing+with+DID%27s%2C+Part+Deux)

~~~
fouc
Interesting hyperledger is backed by the Linux Foundation.. which is a front
for large corporations to try to gain control over linux/FOSS/etc hmm

------
maximilianroos
Does this have any advantage over git trim?

That's worked really well for me

[https://github.com/foriequal0/git-trim](https://github.com/foriequal0/git-
trim)

------
vikin9
Not so fancy, but a one-liner

    
    
      # Remove all local branches for which there is no remote
      git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -D

~~~
toastal
The <() is a Bashism isn't it?

~~~
spyc
Yes. See "Process Substitution" in "man bash". It works great, e.g. with diff
(or meld):

    
    
      # diff -u <(echo $'one\ntwo') <(echo one)
      --- /dev/fd/63  2020-08-13 16:14:44.449379498 +0200
      +++ /dev/fd/62  2020-08-13 16:14:44.450379506 +0200
      @@ -1,2 +1 @@
       one
      -two

~~~
toastal
Gotcha. I wanted to know if it was POSIX compliant (it wasn't clear to me last
time I looked it up).

------
chrisweekly
Amazing timing! I was just auditing a colleague's (admittedly fairly well-
written) shell script for this purpose. Nice to have this alternative.

------
nhumrich
why not just set `git config fetch.prune true`?

~~~
brown9-2
I don’t think this detects a branch that can be deleted after a squash merge
to master

~~~
nhumrich
as long as the remote branch is deleted it does. Both github and gitlab can
delete branch on merge

------
exabrial
requires a python installation which brings a lot of stuff and new
vulnerabilities... instead, see the other post about contributing straight to
the git project

~~~
CognitiveLens
yeah it's been awhile since I've set up a python-ready environment, and trying
to install this reminded me of the challenge of just getting to the expected
starting point.

    
    
      $ pip install git-delete-merged-branches
      zsh: command not found: pip
      $ brew install pip
      Error: No available formula with the name "pip"
      pip is part of the python formula:
        brew install python
      $ brew install python
      ...
      OK
      $ pip install git-delete-merged-branches
      zsh: command not found: pip
      
      (look up how to install pip)
      $ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
      $ python get-pip.py
      WARNING: The scripts pip, pip2 and pip2.7 are installed in 
      '/Users/{me}/Library/Python/2.7/bin' which is not on PATH.
        Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
      Successfully installed pip-20.2.2
      $ pip install git-delete-merged-branches
      zsh: command not found: pip
      (walk away)
    

I know there are solutions to all this, and it's mainly that I don't already
have my $PATH set up the way that pip expects, etc, but really??

~~~
mappu
And - somehow this installed Python 2 in 2020.

~~~
soraminazuki
No, it doesn't. Parent commenter has been macOS stock Python instead of the
Homebrew one.

------
piahoo
this script just removed my local, never pushed, never merged branch

~~~
spyc
Which script are you referring to?

