Live data from Hacker News

I found a useful Git one liner buried in leaked CIA developer docs

spencer.wtf

141–150 of 273 posts

Re: I found a useful Git one liner buried in leaked CIA developer docs

#141

I use `master` in all my repos because I've been using it since forever and it never has once occurred to me "oh shit I better change it to `main` this time in case `master` may offend somebody some day. Unfortunately, that's the last thing on my mind when I'm in programming mode. Now that everything is `master`, maybe it is just a simple git command to change it to `main`. But, my fear is it'll subtly break somethin…

Also, git's "master" branch is named after a master recording or master copy, the canonical original from which duplicates are made. There is literally no reason for it be offensive except for those who retroactively associate the word with slavery.

I'll change my default branches to main when Masterclass change their name to Mainclass

Re: I found a useful Git one liner buried in leaked CIA developer docs

#142

I have a cleanup command that integrates with fzf. It pre selects every merged branch, so I can just hit return to delete them all. But it gives me the opportunity to deselect to preserve any branches if I want. It also prunes any remote branches # remove merged branches (local and remote) cleanup = "!git branch -vv | grep ': gone]' | awk '{print $1}' | fzf --multi --sync --bind start:select-all | xargs git branch -D…

You can pull another branch without switching first: git switch my-test-branch ... git pull origin main:main git rebase main

Likewise with the other way around, just switch pull with push.

Re: I found a useful Git one liner buried in leaked CIA developer docs

#143
post #50
post #29

Earlier quoted context omitted.

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…

I prefer tui's for two reasons. 1. Very used to vi keybindings 2. I like low resources software. I love the ability to open the software in less than a second in a second do what I needed using vi motions. And close it less than a second. Some people will be like you save two seconds trying to do something simple. You lose more time building the tool than you will use it in your life. It's not about saving time. It's…

That’s an excellent way to explain it. I’m already in the shell doing stuff. Whenever I can stay there without sacrificing usability, it’s a big boost.

Re: I found a useful Git one liner buried in leaked CIA developer docs

#144

I use `master` in all my repos because I've been using it since forever and it never has once occurred to me "oh shit I better change it to `main` this time in case `master` may offend somebody some day. Unfortunately, that's the last thing on my mind when I'm in programming mode. Now that everything is `master`, maybe it is just a simple git command to change it to `main`. But, my fear is it'll subtly break somethin…

Also, git's "master" branch is named after a master recording or master copy, the canonical original from which duplicates are made. There is literally no reason for it be offensive except for those who retroactively associate the word with slavery.

Yeah, with replica it made a little sense. Was still silly, but at least the official master/slave terminology actually didn't fully make sense either... So the replica rebrand felt justified to me.

With git it was basically entirely driven by SJW that felt empowered by people accepting the replica rebrand

Re: I found a useful Git one liner buried in leaked CIA developer docs

#145
post #18
post #2

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.

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…

This is how I solve the dependencies with Nix: https://gist.github.com/whazor/bca8b687e26081e77d818bc26033c...

Nix helps Claude a lot with dependencies, it can add stuff and execute the flake as well.

I will come back to you with project itself.

Re: I found a useful Git one liner buried in leaked CIA developer docs

#146
post #140

Earlier quoted context omitted.

> how do you trust the code claude wrote? If that's something you're worried about, review the code before running it. > don't you get anxiety "what if there's an error in tui code and it would mess up my git repo"? I think you might want to not run untrusted programs in an environment like that, alternatively find a way of start being able to trust the program. Either approaches work, and works best depending on wha…

> If that's something you're worried about, review the code before running it. It takes more , not less, time to thoroughly review code you didn't write.

Depends. If I was the one coming up with the implementation anyways, it's basically just the "coding" part that was replaced with "fingers hitting keyboard" and "agents writing to disk", so reviewing the code certainly is faster, you just have to "check" it, not understand it from scratch.

If we're talking receiving random patches where first you have to understand the context, background and so on, then yeah I agree, it'll take longer time probably than what it took for someone to hammer with their fingers. But again, I'm not sure that's how professionals use LLMs right now, vibe-coding is a small hyped world mostly non-programmers seem to engage in.

Re: I found a useful Git one liner buried in leaked CIA developer docs

#147
post #30

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…

I have the same issue. Changes get pushed to gerrit and rebased on the server. This is what I have, though not perfected yet.

  prunable = "!f() { \
  : git log ; \
  target=\"$1\"; \
  [ -z \"$target\" ] && target=$(git for-each-ref --format=\"%(refname:short)\" --count=1 refs/remotes/m/); \
  if [ -z \"$target\" ]; then echo \"No remote branches found in refs/remotes/m/\"; return 1; fi; \
  echo \"# git branch --merged shows merged if same commit ID only\" ;\
  echo \"# if rebased, git cherry can show branch HEAD is merged\"  ;\
  echo \"# git log grep will check latest commit subject only.  if amended, this status won't be accurate\" ;\
  echo \"# Comparing against $target...\"; \
  echo \"# git branch --merged:\"; \
  git branch --merged $target  ;\
  echo \" ,- git cherry\" ; \
  echo \" |  ,- git log grep latest message\"; \
  for branch in $(git for-each-ref --format='%(refname:short)' refs/heads/); do \
   if git cherry \"$target\" \"$branch\" | tail -n 1 | grep -q \"^-\"; then \
    cr=""; \
   else \
    cr=""; \
   fi ; \
   c=$(git rev-parse --short $branch) ; \
   subject=$(git log -1 --format=%s \"$branch\" | sed 's/[][(){}.^$\*+?|\\/]/\\\\&/g') ; \
   if git log --grep=\"^$subject$\" --oneline \"$target\" | grep -q .; then \
    printf \"$cr  $c %-20s $subject\\n\"  $branch; \
   else \
    printf \"$cr  \\033[0;33m$c \\033[0;32m%-20s\\033[0m $subject\\n\"  $branch; \
   fi; \
  done; \
  }; f"
(some emojis missing in above. see gist) https://gist.github.com/lawm/8087252b4372759b2fe3b4052bf7e45...

It prints the results of 3 methods:

1. git branch --merged

2. git cherry

3. grep upstream git log for a commit with the same commit subject

Has some caveats, like if upstream's commit was amended or the actual code change is different, it can have a false positive, or if there are multiple commits on your local branch, only the top commit is checked

Re: I found a useful Git one liner buried in leaked CIA developer docs

#148

I have a cleanup command that integrates with fzf. It pre selects every merged branch, so I can just hit return to delete them all. But it gives me the opportunity to deselect to preserve any branches if I want. It also prunes any remote branches # remove merged branches (local and remote) cleanup = "!git branch -vv | grep ': gone]' | awk '{print $1}' | fzf --multi --sync --bind start:select-all | xargs git branch -D…

You can pull another branch without switching first: git switch my-test-branch ... git pull origin main:main git rebase main

You can also rebase directly on the remote branch

    git fetch
    git rebase origin/main

Re: I found a useful Git one liner buried in leaked CIA developer docs

#149
post #144

Earlier quoted context omitted.

Also, git's "master" branch is named after a master recording or master copy, the canonical original from which duplicates are made. There is literally no reason for it be offensive except for those who retroactively associate the word with slavery.

Yeah, with replica it made a little sense. Was still silly, but at least the official master/slave terminology actually didn't fully make sense either... So the replica rebrand felt justified to me. With git it was basically entirely driven by SJW that felt empowered by people accepting the replica rebrand

imo the `main` thing was mostly driven by people trying to appease the social justice crowd without understanding much about the movement. Its a bit of woo in my mind because there are still systemic injustices out there that are left uncontested, and using main doesn't really contest anything substantial.

I don't really care what the default branch is called tho so I'm willing to play along.

Re: I found a useful Git one liner buried in leaked CIA developer docs

#150
post #140

Earlier quoted context omitted.

> If that's something you're worried about, review the code before running it. It takes more , not less, time to thoroughly review code you didn't write.

Depends. If I was the one coming up with the implementation anyways, it's basically just the "coding" part that was replaced with "fingers hitting keyboard" and "agents writing to disk", so reviewing the code certainly is faster, you just have to "check" it, not understand it from scratch. If we're talking receiving random patches where first you have to understand the context, background and so on, then yeah I agree…

> you just have to "check" it, not understand it from scratch.

How can you "check" that which you don't "understand"?

> I'm not sure that's how professionals use LLMs right now

I'm a professional and I can tell you how I use LLMs: I write code with their assistance, they don't write code for me.

The few times I let Claude or Copilot loose, the results were heartbreaking and I spent more time reviewing (and then discarding) the code than what it took me to later write it from scratch.

Post reply on HN