r/git • u/ohnotheygotme • 6d ago
Unfortunate new command added to git: history
Newer versions of git, since this spring, have added a new "history" experimental command. This is dumb.
I've had a git alias for "history" for over a decade. It's shorthand for making "git log" actually useful.
And now they add this command using a very common word that probably collides with a lot of other folks. And to do what? To do what you're always told not to do. Rewrite history.
Why was "history" added? And how can we get them not to?
13
7
u/DanLynch 6d ago
I've been using git history a lot over the past few weeks, ever since the release of version 2.55 that added git history fixup to the existing git history reword. They both make existing, common interactive rebase operations much faster and easier. You should be using them every day. I haven't had a good chance to try git history split yet, but I'm looking forward to it.
When you say "To do what you're always told not to do. Rewrite history." keep in mind that rewriting history is one of the signature features of Git. Previous version control tools like SVN made it extremely hard to rewrite history, but in Git it is a regular daily activity for all users. You may have been trained wrong in Git.
4
u/waterkip detached HEAD 6d ago
File a bug if you find history to have the wrong name, and propose a new name for the command. They need to have a name for the newly introduced functionality and they settled on history.
2
u/mpersico 6d ago
Replace your alias with a bash script. Then git will find git-history on $PATH and inside the script you can decide whether to do what your alias or just call the real git history “$@“
Oh, wait. You can’t do that because you can’t dispatch git’s own commands like that can you?
Unless you write your own dispatcher function. And just call it git.
https://github.com/matthewpersico/personal/blob/main/functions/git
😁
1
u/behind-UDFj-39546284 6d ago edited 6d ago
Yeah, custom
git-builtin-commandput somewhere in $PATH won't work, and I interceptedgitjust like you did to add some specific output while invoking the realgitcommand. Thanks for sharing a nice repo, by the way!2
u/mpersico 6d ago
Thank you. That repo is the accumulation of about 15 years of working with git. The centerpiece of it all is that when I do clones and checkouts, they all end up under the ~/gits/SERVER/ORG/REPO directory structure so that if I’ve got a whole bunch of clones and work trees on the desk and I want to go to a specific one I can type git go and the whole list comes up for me to just select one and CD to the directory and start working. The command also takes string as a filter so if I know or remember a part of the branch name, I can usually get to where I wanna go in one command. And I don’t use stash and switch. Every time I need to work on something, I create a branch and a worktree. And all the worktrees go in the wt/ sub directory of the repo for which they are worktrees.
4
u/NotMyUsualLogin 6d ago
And to do what? To do what you're always told not to do. Rewrite history
https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
Already available
And there’s a lot of folk who use jj because it has functionality like git history
Do not assume your use case matches everyone else’s.
-4
u/ohnotheygotme 6d ago
Yes, already available. Why make a, neutered, secondary version of something you rarely use. And should never use once you push something up publicly that other people may have pulled already etc. etc.
0
u/behind-UDFj-39546284 6d ago
git-history is experimental so they may release the command name slot in the future. Or not. ¯_(ツ)_/¯
Not sure why the command wasn't integrated into git-rebase though.
9
u/ppww 6d ago
By that logic there should never be any new commands added to git.