News for hackers. Stuff that matters.
Re:Oh Shit, Git? by recursive on Sunday August 16, 2020 @12:54AM (#24175258)
It's not that good. For one, rebase mutates history. Also the ui is confusing and inconsistent even if the data model is pure and beautiful.
Re:Oh Shit, Git? by mb7733 on Sunday August 16, 2020 @02:02AM (#24175606)
Rebase does not mutate. It creates new commits and updates the rebased branch to point at them. The original commits still exist (even if no other branch points at them).

Git commits are never mutated. They are referred to by a hash of their content after all.

Re:Oh Shit, Git? by dreamcompiler on Sunday August 16, 2020 @02:22AM (#24175692)
Rebase sure seems like it mutates.

What's the UI for getting at those old commits? Is it possible to get a true chronological log from them? Do they stay around forever or do they get garbage collected eventually?

Re:Oh Shit, Git? by RichardCA on Sunday August 16, 2020 @02:51AM (#24175811)
Good:

  git log --all --graph --oneline --reflog
Better:

  git config --global alias.lg "log --date=format-local:'%Y-%m-%d %H:%M:%S' --pretty=format:'%cd %<(20,trunc)%an %C(auto)%h%Creset%C(auto)%d%Creset %s'"

  git lg --all --graph --reflog
> Is it possible to get a true chronological log from them?

The output of git log with --graph is not chronological, because it does a topological traversal of the commit graph.

> Do they stay around forever or do they get garbage collected eventually?

They get garbage collected eventually. As a rule you should not assume dangling commits are safe. If you need to keep one, assign a trivial branch name to it.

Re:Oh Shit, Git? by mb7733 on Sunday August 16, 2020 @10:13AM (#24177981)
> What's the UI for getting at those old commits?

The same as any other commit. You can check them out by referring to their hash, by referring to any tags that point to them, or any branch that points at them.

The other reply gives options assuming the commits have been orphaned (no tags or branches point at them).

Re:Oh Shit, Git? by recursive on Sunday August 16, 2020 @02:29AM (#24175730)
As far as I know, commits that were once ancestors of a branch can sometimes no longer be ancestors of that branch. If that's not a mutation, then the word is not as useful as I thought.
Re:Oh Shit, Git? by usr1106 on Sunday August 16, 2020 @03:27AM (#24175947)
Branches are just pointers into a graph of commits. The graph cannot be mutated (it can be pruned by garbage collection but that does never happen related to an oh shit event, it takes weeks even in a heavily modified repo). The pointers can be modified to point anywhere else in the graph, which makes things look mutated without being mutated. Using reflog you can get your back to where your pointers pointed to at any earlier point of time.
Re:Oh Shit, Git? by mb7733 on Sunday August 16, 2020 @10:25AM (#24178080)
I'd say it's a pretty standard use of the word. Branches are analogous to pointers. If a program changes where the pointer points, it has not mutated any values, besides the pointer itself.

(Obviously the branch/pointer itself is mutable.)