NHacker Next
  • new
  • past
  • show
  • ask
  • show
  • jobs
  • submit
I found a useful Git one liner buried in leaked CIA developer docs (spencer.wtf)
lloeki 13 minutes ago [-]
I've had essentially that - if a bit fancier to accept an optional argument as well as handle common "mainline" branch names - aliased as `git lint` for a while:

    [alias]
        lint = !git branch --merged ${1-} | grep -v -E -e '^[*]?[ ]*(main|master|[0-9]+[.]([0-9]+|x)-stable)$' -e '^[*][ ]+' | xargs -r -n 1 git branch --delete
so:

    git pull --prune && git lint
sits very high in my history stats
arusahni 19 minutes ago [-]
I use this alias:

    prune-local = "!git fetch -p && for branch in $(git branch -vv | awk '/: gone]/{if ($1!=\"\*\") print $1}'); do git branch -d $branch; done"
1. Fetch the latest from my remote, removing any remote tracking branches that no longer exist

2. Enumerate local branches, selecting each that has been marked as no longer having a remote version (ignoring the current branch)

3. Delete the local branch safely

whazor 38 minutes ago [-]
I currently have a TUI addiction. Each time I want something to be easier, I open claude-code and ask for a TUI. Now I have a git worktree manager where I can add/rebase/delete. As TUI library I use Textual which claude handles quite well, especially as it can test-run quite some Python code.
firesteelrain 19 minutes ago [-]
Can you explain TUI? I have never heard this before
GCUMstlyHarmls 4 minutes ago [-]
Eg: lazygit https://github.com/jesseduffield/lazygit?tab=readme-ov-file#... https://github.com/sxyazi/yazi https://github.com/darrenburns/posting or I guess Vim would be a prominent example.

Peoples definitions will be on a gradient, but its somewhere between CLI (type into a terminal to use) and GUI (use your mouse in a windowing system), TUI runs in your terminal like a CLI but probably supports "graphical widgets" like buttons, bars, hotkeys, panes, etc.

Bjartr 11 minutes ago [-]
Terminal User Interface, contrasting with a Graphical User Interface (GUI). Most often applied to programs that use the terminal as a pseudo-graphical canvas that they draw on with characters to provide an interactive page that can be navigated around with the keyboard.

Really, they're just a GUI drawn with Unicode instead of drawing primitives.

Like many restrictions, limiting oneself to just a fixed grid of colored Unicode characters for drawing lends itself to more creative solutions to problems. Some people prefer such UIs, some people don't.

ses1984 17 minutes ago [-]
Terminal UI.
KPGv2 4 minutes ago [-]
it's the name gen Z and gen alpha puppyn00bs have given to what us old heads have always called CLIs

on tik too young folks are always discovering "revolutionary" things and giving them names, ignoring they're either super mundane, or already have a name

on one hand, i absolutely LOVE the passion for discovery and invention

on the other hand, if you're 19yo you probably didn't discover something revolutionary

Trufa 19 minutes ago [-]
The amount of little tools I'm creating for myself is incredible, 4.6 seems like it can properly one/two shot it now without my attention.

Did you open source that one? I was thinking of this exact same thing but wanted to think a little about how to share deps, i.e. if I do quick worktree to try a branch I don't wanna npm i that takes forever.

Also, if you share it with me, there's obviously no expectations, even it's a half backed vibecoded mess.

elliotbnvl 18 minutes ago [-]
The deps question is huge, let me know if you solve it.
hattmall 12 minutes ago [-]
What are some examples of useful TUI you made? I'm generally opposed to the concept
lionkor 28 minutes ago [-]
That sounds like a complete waste of time and tokens to me, what is the benefit? So each time you do something, you let Claude one shot a tui? This seems like a waste of compute and your time
htnthrow11220 20 minutes ago [-]
They said each time they want something to be easier, not each time they do something. And they didn’t mention it has to be one-shot. You might have read too quickly and you’ve responded to something that didn’t actually exist.
bmacho 9 minutes ago [-]
Now that I think about it, if Claude can put most useful functions in a TUI and make them discoverable (show them in a list), than this could be better than asking for one-liners (and forgetting them) every single time.

Maybe I'll try using small TUI too.

MarsIronPI 23 minutes ago [-]
On the contrary. Once these tools exist they exist forever, independently of Claude or a Claude Code subscription. IMO this is the best way to use AI for personal use.
duneisagoodbook 22 minutes ago [-]
yeah! they should focus on more productive pursuits, like telling people online what to do with their time and resources.
morissette 20 minutes ago [-]
And these are things outside of our control.
stabbles 2 minutes ago [-]
Missed opportunity to call it `git ciao`
jakub_g 10 minutes ago [-]
The main issue with `git branch --merged` is that if the repo enforces squash merges, it obviously won't work, because SHA of squash-merged commit in main != SHA of the original branch HEAD.

What tools are the best to do the equivalent but for squash-merged branches detections?

Note: this problem is harder than it seems to do safely, because e.g. I can have a branch `foo` locally that was squash-merged on remote, but before it happened, I might have added a few more commits locally and forgot to push. So naively deleting `foo` locally may make me lose data.

34 minutes ago [-]
jo-m 15 minutes ago [-]
I have something similar, but open fzf to select the branches to delete [1].

    function fcleanb -d "fzf git select branches to delete where the upstream has disappeared"
        set -l branches_to_delete (
            git for-each-ref --sort=committerdate --format='%(refname:lstrip=2) %(upstream:track)' refs/heads/ | \
            egrep '\[gone\]$' | grep -v "master" | \
            awk '{print $1}' | $_FZF_BINARY --multi --exit-0 \
        )

        for branch in $branches_to_delete
            git branch -D "$branch"
        end
    end
[1]: https://github.com/jo-m/dotfiles/blob/29d4cab4ba6a18dc44dcf9...
gritzko 18 minutes ago [-]
Speaking of user friendliness of git UI. I am working on a revision control system that (ideally) should be as user friendly as Ctrl+S Ctrl+Z in most common cases. Spent almost a week on design docs, looking for feedback (so far it was very valuable, btw)

https://replicated.wiki/blog/partII.html#navigating-the-hist...

oniony 18 seconds ago [-]
Have you tried Jujutsu. If you want to make a better VCS, your baseline should be Jujutsu and not Git in my opinion, because Jujutsu already deals with a lot of Git pain points.
1a527dd5 28 minutes ago [-]
I use

    #!/bin/sh
    
    git checkout main
    git fetch --prune
    git branch | grep -v main | xargs --no-run-if-empty git branch -D
    git pull
Save that next to your git binary, call it whatever you want. It's destructive on purpose.
schiffern 7 minutes ago [-]
"ciaclean" is a nice touch.

I assume CIA stands for Clean It All.

plufz 2 minutes ago [-]
I assume it means mess up commit history and install ”our” BDFL.
sammyteee 5 minutes ago [-]
"Clean It All, Clean" :P
sigio 31 minutes ago [-]
I've had this command as 'git drop-merged' for a few years now (put as a script in your path named git-drop-merged:

  #!/bin/sh
  git branch --merged | egrep -v "(^\*|master|main|dev)" | xargs --no-run-if-empty
  git branch -d
Arch-TK 9 minutes ago [-]
Unfortunately doesn't work if the project you work on squashes everything :(
dewey 32 minutes ago [-]
If you are using Fork.app on Mac as your git client, this now exists (For one month now) there too: https://github.com/fork-dev/Tracker/issues/2200#issuecomment...
19 minutes ago [-]
parliament32 34 minutes ago [-]
So effectively "I just discovered xargs"? Not to disparage OP but there isn't anything particularly novel here.
jimmydoe 18 minutes ago [-]
And they have to learn that from cia?

That says so much about the generation we are in, just don’t go to school but learn math from mafia

skydhash 5 minutes ago [-]
People really do need to read the “Unix Power Tools” book and realize their problem has been solved for decades.
cgfjtynzdrfht 20 minutes ago [-]
[dead]
galbar 36 minutes ago [-]
The git plugin in oh-my-zsh has an alias for this: gbda

It also has one for squash-merged branches: gbds

Very useful I've been using them for years

blakesterz 29 minutes ago [-]
That's handy! I just started using oh-my-zsh and I feel like I know about 4% of useful things it can do so far.
gjvc 21 minutes ago [-]
"trapd00r" is the theme you want, if only because the name is cool
morissette 21 minutes ago [-]
Why is this even a blog post. Tell the young ones to RTFM.
Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact
Rendered at 14:58:32 GMT+0000 (Coordinated Universal Time) with Vercel.