5 ms·
Git: Deletion of merged branches taken beyond shell hacks
- chmaynard 6y agoInstead 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 6y agoMaybe? We've had mentorships over the last couple of years trying to introduce some crypto features to Git, and they've been rebuffed.
- justincormack 6y agoWhat sort of features?
- RyJones 6y agogit-dids. 2019: https://wiki.hyperledger.org/display/INTERN/Git+signing+with+DIDs https://wiki.hyperledger.org/display/INTERN/Git+signing+with... 2020: https://wiki.hyperledger.org/display/INTERN/Git+Commit+Signing+with+DID%27s%2C+Part+Deux https://wiki.hyperledger.org/display/INTERN/Git+Commit+Signi...
- fouc 6y agoInteresting hyperledger is backed by the Linux Foundation.. which is a front for large corporations to try to gain control over linux/FOSS/etc hmm
- justincormack 6y agoGood luck keep working on it!
- chrisweekly 6y agoAmazing timing! I was just auditing a colleague's (admittedly fairly well-written) shell script for this purpose. Nice to have this alternative.
- maximilianroos 6y agoDoes 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
- exabrial 6y agorequires a python installation which brings a lot of stuff and new vulnerabilities... instead, see the other post about contributing straight to the git project
- deleted 6y ago[deleted]
- CognitiveLens 6y agoyeah 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??
- fuhrysteve 6y agoTo be fair, python isn't the only language whose package management system is all but incoherent to folks who don't use python every day (and sometimes even to them!). npm is pretty rough to get setup too, and you run into a lot of issues similar to this.
- wonderlg 6y agoI don’t think Node has trouble from the very first installation. A brew install will set you up with the latest version of both node and npm and they will work. At most you’ll have trouble running the right version (rare nowadays, unlike in pre-v1 days)
- vikin9 6y agoNot 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
- lixtra 6y ago> # Remove all local branches for which there is no remote The merged branches part is missing.
- toastal 6y agoThe <() is a Bashism isn't it?
- gravitas 6y ago< is a redirect operator, the out of the item on the right is redirected to the in of the item on the left; () are just grouping operators like math to ensure that bit is self contained inline for the parser.
- inyourtenement 6y agoThat might be a way to remember what it does, but I don't think that's how it works. Try doing `echo <(ls)` to see how it differs. Or, from the manpage: > Process substitution is supported on systems that support named pipes (FIFOs) or the /dev/fd method of naming open files. It takes the form of <(list) or >(list). The process list is run with its input or output connected to a FIFO or some file in /dev/fd. The name of this file is passed as an argument to the current command as the result of the expansion. If the >(list) form is used, writing to the file will provide input for list. If the <(list) form is used, the file passed as an argument should be read to obtain the output of list.
- nhumrich 6y agowhy not just set `git config fetch.prune true`?
- brown9-2 6y agoI don’t think this detects a branch that can be deleted after a squash merge to master
- nhumrich 6y agoas long as the remote branch is deleted it does. Both github and gitlab can delete branch on merge
- spyc 6y ago`git fetch --prune` only deletes remote-tracking branches (`refs/remotes/<remote>/<branch>`) but not local tracking branches (`refs/heads/<branch>`).
- piahoo 6y agothis script just removed my local, never pushed, never merged branch
- spyc 6y agoWhich script are you referring to?