Re:Git: Deletion of merged branches taken beyond shell hacks
by vikin9 on Wednesday August 12, 2020 @05:25PM
(#24137188)
Not so fancy, but a one-liner
[ Parent
| on HN ]
Re:Git: Deletion of merged branches taken beyond shell hacks
by lixtra on Wednesday August 12, 2020 @11:48PM
(#24139774)
> # Remove all local branches for which there is no remote
The merged branches part is missing.
Re:Git: Deletion of merged branches taken beyond shell hacks
by vikin9 on Thursday August 13, 2020 @09:39AM
(#24143202)
I setup Github repos to automatically delete merged branches - in this case, the remote counterpart will be gone. There might be just the following missing to sync remove `origin/*` branches locally: `git fetch --prune`
Re:Git: Deletion of merged branches taken beyond shell hacks
by lixtra on Thursday August 13, 2020 @12:33PM
(#24145198)
Your newly created local branch might be gone as well.
Re:Git: Deletion of merged branches taken beyond shell hacks
by spyc on Thursday August 13, 2020 @10:18AM
(#24143562)
Careful with "git branch -D" — it's a sharp knife.
Re:Git: Deletion of merged branches taken beyond shell hacks
by toastal on Thursday August 13, 2020 @03:08AM
(#24140729)
The <() is a Bashism isn't it?
Re:Git: Deletion of merged branches taken beyond shell hacks
by spyc on Thursday August 13, 2020 @10:15AM
(#24143538)
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
Re:Git: Deletion of merged branches taken beyond shell hacks
by toastal on Thursday August 13, 2020 @12:10PM
(#24144887)
Gotcha. I wanted to know if it was POSIX compliant (it wasn't clear to me last time I looked it up).
Re:Git: Deletion of merged branches taken beyond shell hacks
by gravitas on Thursday August 13, 2020 @08:05AM
(#24142479)
< 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.
Re:Git: Deletion of merged branches taken beyond shell hacks
by inyourtenement on Thursday August 13, 2020 @11:32AM
(#24144396)
That 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.