frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

The Git history command deserves more attention

https://lalitm.com/post/git-history/
53•turbocon•1h ago

Comments

nine_k•1h ago
In short, newer versions of git implemented three really frequent use cases of `git rebase --interactive` as separate lower-friction commands. Apparently they only work when there are no conflicts.
BobbyTables2•48m ago
Wonder if the history command is all that useful.

I prefer the interactive rebase and use it frequently.

Would much rather “visually” move commits around than accidentally aim “git history” at an orphaned commit hash no longer in my local branch.

skydhash•54m ago
> Working with lots of changes in parallel on git can be painful. You end up juggling branches and commits, and running scary rebase -i commands that can leave your tree in a half-broken state if you so much as sneeze.

I think that only happens when you work on code as text files (i.e character streams) instead of code (i.e structured content with meaning). Like you have commit A and commit B that is in conflict, you should be glad because that's a rough signal that the intent of A and B differs. Your goal should be to think about how to compose A and B so that both intent survives (unless one supersedes the other). Which means you should be at least familiar with A and B.

The issue I found with people that fears conflict is that they often don't understand either A or B (or both). So they are a bad candidate to actually do the operation. It's not a matter of git's cli interface, it's a matter of codebase comprehension and how well you're familiar with the changes in question.

thfuran•32m ago
Git is the one treating code like a text file instead of code.
UnfitFootprint•26m ago
I pull out difftastic when it’s all too hard for this. Diffs based off tree sitter
bulatb•27m ago
I can fully understand a conflict, know it's coming, and fear it anyway because I'll have to deal with Git being Git to fix it.
seba_dos1•18m ago
Such as?

When you merge a commit in that changed a file that has been already changed since the common ancestor, Git runs a tool of your choice on this file. If the tool fails, it marks the file as needing a merge and doesn't let you commit it until you unmark it to confirm that you have merged it manually. In case of octopus merges, it will just abort early. That's basically its whole behavior when it comes to conflicts.

jolmg•32m ago
> scary rebase -i commands that can leave your tree in a half-broken state if you so much as sneeze

`git rebase --abort` exists. One can also set a tag or something before doing the rebase, do whatever, then `git reset --hard $set_tag` to go back. Nothing to be scared of. Not like the prior state is lost.

catlifeonmars•28m ago
Do you use git reflog?
jolmg•17m ago
One can also use that, or just `git log -n1` and taking note of the commit hash. So many options.
rmunn•4m ago
I have so many branches named `temp` or `before-rebase` for exactly that reason; I'm using them effectively as tags, but branches can be moved around with less ceremony than tags (since tags are designed to be for things like v1.2.3, placed once and then almost never moved again), so I usually just do `git branch before-rebase/some-feature` before running a big `rebase -i`.

I've almost never needed to run `get reset before-rebase`. But I have often done `git log -p before-rebase` and compared that to the post-rebase state of the branch, to ensure that the merge-conflict resolution(s) that came up during the rebase haven't accidentally introduced an unintended change.

paularmstrong•30m ago
`git history split` is really going to help me help juniors break up their large PRs into smaller more concise changes. If only it had the option to split an entire branch in two easily.
catlifeonmars•29m ago
What does it mean to split a branch in two?
rmunn•12m ago
Probably to take a series of commits and decide "this one goes on branch A, this one on branch B", e.g. if you intermingled fixing bug A and B in the same branch, you could more easily go through and assign each commit to a new branch.

The existing workflow for that would be (there are several possible workflows, but this is what I would do):

  git checkout intermingled-branch
  git branch bugfix-A
  git branch bugfix-B
  git checkout bugfix-A
  git rebase -i
  # Edit the file, keep commits that fix bug A, drop commits that fix bug B
  git push origin bugfix-A:bugfix-A
  git checkout bugfix-B
  git rebase -i
  # Edit the file, keep commits that fix bug B, drop commits that fix bug A
  git push origin bugfix-B:bugfix-B
hahahaa•21m ago
I like to be like an accountant. No editing history. Create a new "journal entry" (i.e. commit) to fix.
what•11m ago
You probably shouldn’t be committing things that are broken…
seba_dos1•6m ago
Commit graph is just a data structure. Sometimes it represents a "history", sometimes other things.

Personally, I like it when project's repository represents the history of the project rather than the history of random things developers do on their machines.

bentt•20m ago
Granted, I have a perspective of a game dev, but this kind of repo defiling just gives me the willies. IMO instead of finding a common ancestor and altering it, just make the desired change upstream and merge it to where it’s needed. If you can’t do that then you have already made a deal with the devil and might reconsider your approach. KISS
shepmaster•15m ago
> That last part goes further than git rebase --update-refs, which only moves refs sitting inside the range you’re actively rebasing. git history instead finds and rewrites every local branch descended from the commit (while also having an option to limit it to only the current branch).

I'm reading that to mean that when I use `git rebase --update-refs` in this situation, where I've currently checked out `D` and update `B` to `B'`:

  A ──► B ──► C ──► D  
        │              
        └───► E        
I'll end up with this state, where `E` remains untouched?

  A ──► B' ─► C' ─► D'  
                      
  A ──► B ──► E        
(EDIT: Originally I had `E` point to `B'`, which doesn't make sense)

If I use `git history fixup`, it would also update `E` and end up with this?

  A ──► B' ─► C' ─► D'  
        │              
        └───► E'        
If that's the case, is there a way to get `git rebase` to have the same behavior? I've got decades of `git rebase` burned into my fingers at this point.
jolmg•13m ago
> I'll end up with this state, where `E` remains untouched?

Can't, because a commit's hash takes into account the parent hashes.

Haven't used --update-refs, but reading it, it should result in your third graph. So,

> is there a way to get `git rebase` to have the same behavior?

is already the case.

rmunn•10m ago
Unless E remained untouched because it was not rewritten, and ended up staying parented on B instead of getting reparented onto B'.

Which is usually not what you want; most of the time you want E', which is E reparented onto B'. But sometimes you want E to remain untouched and stay parented on the original B. Depends on the situation.

jolmg•9m ago
Exactly, but the second graph where untouched E is reparented to B' is not something that git would allow.
shepmaster•6m ago
Ah, good catch. That's more of a graphic issue and not what I was trying to express. Updated the OP.
lelandfe•11m ago
See: https://blog.hot-coffee.dev/en/blog/git_update_refs/
shepmaster•3m ago
I'm not sure that answers my question. That shows a linear set of branches (my-feature-v3 depends on my-feature-v2 depends on my-feature-v1 depends on main). I'm asking about the case where two or more branches fork from a common ancestor and you want to fix the common ancestor.

Private Browsing Myths: What Incognito Mode Doesn't Hide

https://mysysinfo.com/blog/private-browsing-myths
1•hackstar•1m ago•0 comments

Meta Is Flooding the Market with Smartglasses. Privacy Advocates Are Up in Arms

https://www.wsj.com/tech/ai/meta-is-flooding-the-market-with-smartglasses-privacy-advocates-are-u...
1•fortran77•1m ago•1 comments

Ask HN: What hardware hobby would you recommend to a software engineer?

1•merek•2m ago•0 comments

You can now chat using RSS

https://coywolf.com/news/social-media/you-can-now-chat-using-rss-well-sort-of/
2•twapi•5m ago•0 comments

Ask HN: How has the software industry changed for you personally?

3•brindidrip•8m ago•0 comments

Detecting Malicious Code at Scale

https://www.datadoghq.com/blog/engineering/scaling-malicious-code-detection/
3•crashpn•10m ago•0 comments

Fundamentals of Wireless Communication

https://web.stanford.edu/~dntse/wireless_book.html
3•teleforce•13m ago•0 comments

Sony Nerfs Videogame Ownership

https://www.eff.org/deeplinks/2026/07/sony-nerfs-videogame-ownership
2•Jimmc414•15m ago•2 comments

Show HN: GLM-5.2 is now available via Canopy Wave

https://twitter.com/CanopyWave_AI/status/2076667973616779441
2•Rossmax•15m ago•0 comments

Rubio announces campaign to 'dismantle' International Criminal Court

https://www.upi.com/Top_News/US/2026/07/13/rubio-campaign-dismantle-international-criminal-court/...
2•Bondi_Blue•16m ago•0 comments

Show HN: Zenveil-Security scanning for AI-generated code

https://zenveil.dev
2•Rachel28•17m ago•0 comments

Georgia family says they're forced to sell home to power AI data centers

https://www.cbsnews.com/news/georgia-power-ai-data-centers-eminent-domain/
3•rhaynes•18m ago•0 comments

Satellite Tracker – Live Map of Starlink and 30k Satellites

https://satellitemap.space/
2•rolph•28m ago•0 comments

Ask HN: Why does Chrome use 100+ mb of memory per tab?

3•Uptrenda•29m ago•0 comments

Ask HN: What is the one YouTube channel you recommend I subscribe to?

2•chirau•31m ago•1 comments

#793 – GPT 5.6 Sol solves it's third Erdos Problem – Two primitives gone

https://twitter.com/i/status/2076778478326653431
4•guywithabowtie•33m ago•1 comments

SCOTUS slip opinion: Cisco granted immunity in building China's "Golden Shield"

https://www.courtlistener.com/opinion/10878537/cisco-systems-inc-v-doe/
3•Jimmc414•35m ago•1 comments

Zig Creator Calls Spade a Spade, Anthropic Blows Smoke

https://raymyers.org/post/zig-creator-calls-spade-a-spade/
2•plinkplonk•37m ago•1 comments

China's Robotics Dream Began in 1972

https://www.chinatalk.media/p/chinas-father-of-robotics
2•gwintrob•38m ago•0 comments

Poorly Aged 80s Commercials [video]

https://www.youtube.com/watch?v=3rxiEaJbxnI
2•Bender•38m ago•0 comments

What will be left for us to work on?

https://www.normaltech.ai/p/what-will-be-left-for-us-to-work
2•randomwalker•39m ago•0 comments

Show HN: Melodusk – AI Music Generator and music tools in the browser

https://melodusk.ai
2•akseli_ukkonen•41m ago•0 comments

Lessons of Darkness

https://en.wikipedia.org/wiki/Lessons_of_Darkness
2•throwoutway•41m ago•0 comments

Building Food Metadata with LLM Juries

https://careersatdoordash.com/blog/building-food-metadata-with-llm-juries-context-optimization-mu...
5•tie-in•42m ago•0 comments

Boom? If AI Sales in the US Go South, Let's Not Bail Out Big Money Bettors

https://www.nationalmemo.com/ai-bubble-2677214150
5•baranul•43m ago•0 comments

Be a Star or a Janitor

https://99d.substack.com/p/be-a-star-or-a-janitor
2•iacguy•46m ago•0 comments

Token overhead in coding agents: the task used 0.67% but overhead used the rest

https://praveenvijayan.substack.com/p/your-agent-spends-99-of-its-tokens
4•praveenvijayan•47m ago•0 comments

Is x86 ready to ACE it?

https://chipsandcheese.com/p/is-x86-ready-to-ace-it
3•mfiguiere•48m ago•0 comments

The Economics of Recursive Self-Improvement [pdf]

https://elasticity.institute/rsi-paper.pdf
4•apsec112•48m ago•0 comments

A better rsync based on fountain codes

https://twitter.com/doodlestein/status/2075711880426062074
2•MrBuddyCasino•51m ago•0 comments