Highlights from Git 2.54

(github.blog)

74 points | by ingve 2 days ago

8 comments

  • charles_f 5 minutes ago
    git history makes me think of git revise^1, which gives you a bunch of handy tools to changes your history, move commits around, remove some of them, cut them (which git history now does). I found it very handy in the past

    1: https://git-revise.readthedocs.io/en/latest/man.html

  • ajoberstar 2 days ago
    Nice to see some seemingly jujutsu inspired features getting into Git core.

      git history reword ~= jj describe
    
      git history split ~= jj split
    
    https://git-scm.com/docs/git-history

    https://www.jj-vcs.dev/latest/cli-reference/#jj-describe

    https://www.jj-vcs.dev/latest/cli-reference/#jj-split

    • wakawaka28 45 minutes ago
      If this is meant to be a dig, you should keep in mind how much jj owes to git.
      • IshKebab 31 minutes ago
        I don't know if it was meant to be a dig but I hope you don't think the fact that Git was a big advancement on SVN means it doesn't deserve any criticism.

        It's very widely remarked that the Git CLI is pretty miserable, and as soon as a better (so I hear) alternative comes along they suddenly realise and start improving it... This happens all the time in software.

        Some software has crap UX or missing obvious features (e.g. comments in package.json). People try and improve it but are rebuffed because the maintainers claim it's fine as it is. Effort goes elsewhere to a competitor project which starts to attract users. Maintains of the original project have a sudden and coincidental change of heart!

    • aulin 2 hours ago
      Not familiar with jj and don't want to get into bike shedding, but how is describe supposed to be a good name for history rewrites?
      • roblabla 2 hours ago
        jj describe gives a name to a commit. In jj, everything rewrites the history, so there's no real point in calling it out in the command name since it's just the default behavior.
      • auscompgeek 2 hours ago
        describe is also the command you can use to edit the commit message of the change you're currently drafting. In jj there's no staging area, every modification to the working tree immediately gets integrated into the current commit. (This means if you have no diff in your working tree, you're actually on an empty commit.)
      • baq 1 hour ago
        in jj the history has mutable and immutable commits.
      • skydhash 2 hours ago
        Not really familiar too, but jj has everything committed by default (no index, staging area, and uncommitted changes). You use ‘jj new’ to stop adding changes to the current commit.

        ‘jj describe’ lets you add a message to a commit as it’s not there by default.

  • ufo 2 hours ago
    I have always had this problem with hooks and new contributors: since hooks don't run by default if you just clone the repository, my open source projects get many PRs from new contributors that did not run the linting and commit hooks. I understand there's a security reason for this but what workflows have worked best for you to get everyone to run the hooks? And do you think the new config-based hooks can help new contributors?
    • Sol- 4 minutes ago
      I always considered hooks a nice to have feature for devs to already validate that their PRs will probably satisfy certain CI checks. If they don't install or run them for whatever reason, it's on them to do another iteration and update the code to make it mergeable if CI complains. So I usually considered it fine that they are only opt-in, since the merge will be gated by a CI outside of the dev's control anyway.
    • sethops1 2 hours ago
      > what workflows have worked best for you to get everyone to run the hooks

      By running the linters and any other checks on CI instead.

      • jayd16 5 minutes ago
        Why waste a round trip, build time, loss of flow and CI machine queue wait time when you can catch things early?

        CI should also run all the checks but CI checks are not a replacement for local hooks. LFS and things like it can't be implemented as remote CI checks.

      • baq 2 hours ago
        autoformatter and autofix linter results can be committed and pushed by CI into the PR branch itself. this is a pain sometimes, but as a repo owner it should protect your sanity.
        • sgarland 1 hour ago
          Yep. Nothing I hate more than some trivial formatting error that could easily fix itself halting CI. I am all for consistent formatting and linting, I just think it should be silently handled without fuss.
        • skydhash 2 hours ago
          I just add a check workflow that test that the files are well formatted and linted. If it passes, one of the key things I check are changes to the configuration. Some tools allows for bypass comments, so I keep an eye out for those too.
      • ufo 2 hours ago
        We do run the linter on CI as well, but I think our comitters would get faster feedback if they ran those checks locally.
        • lou1306 1 hour ago
          Well you can tell them to please enable hooks in the PR guidelines, but you cannot really police what they do or don't run on their own machines.
        • esafak 1 hour ago
          You can issue installation instructions on linter failure in CI.
      • IshKebab 2 hours ago
        As well, not instead. Just add `pre-commit run -a` to your CI. Job done.

        It's still annoying for new contributors though because they might not know how to set up pre-commit (which was quite a pain until recently because it's written in Python).

        • Flimm 1 hour ago
          To clear up any confusion, Git runs pre-commit hooks, and they can be written in any programming language. There's a completely separate and independent project that gave itself the confusing "pre-commit" name, and it is written in Python. This project aims to make it easier to configure pre-commit hooks. An alternative to it is "prek", written in Rust.
          • sgarland 1 hour ago
            Yes, and I hate it so, so much, and frankly don’t get the appeal. You want one-click installation of hooks? Bundle a shell script called run_first.sh that symlinks the hooks into .git.
            • IshKebab 29 minutes ago
              The pre-commit tool does way more than that. For example the clang-format hook will download and run a specific version of clang-format.
    • jbverschoor 1 hour ago
      I don't want you to run arbitrary hooks on my machine. As with CI/CD... your hooks should simply point to a script instead
      • jayd16 34 minutes ago
        Ok well what about when I pay you and give you a local machine to work on?

        Can I pay you to run hooks on the work machine I own because it saves a lot of work on the share build machines? Can we talk about making that situation less error prone?

    • purerandomness 1 hour ago
      In PHP, an established tool is adding GrumPHP [0] to your dependencies.

      It will then handle git hooks on each commit via composer script by default (but can be omitted per commit).

      [0] https://github.com/phpro/grumphp

    • sestep 1 hour ago
      I agree with the other replies saying to just run the checks in CI and have the CI error message mention how to install the pre-commit hook.

      I'm glad cloning a repo doesn't automatically install hooks since I strongly dislike them: I often use Git commands in the terminal but sometimes I use the VS Code UI to commit, and it's extremely frustrating when simply creating a commit runs for several seconds because of some pre-commit hook.

      • sgarland 1 hour ago
        There’s almost certainly a way to make VS Code use --no-verify.
    • scq 1 hour ago
      The approach some JS projects have taken is to use Husky, which automatically sets up the git hooks when you install the project's dependencies during development.
    • 1718627440 1 hour ago
      My project needs other things on setup as well, so I just have a setup script in my repo. `mv hooks/foo .git/hooks` is then just yet another step.
    • XorNot 1 hour ago
      I add an autogen.sh script to all my repositories that does things like this as it's first action.
      • misnome 1 hour ago
        You can also set up a central git template repository, so hooks get automatically added into every repository you clone
  • jinushaun 1 hour ago
    `git history reword` is great. Using `git rebase -i` just to fix a spelling error is overkill and doesn’t actually do what I want.
  • greg_dc 1 hour ago
    Those new git history commands will save me an average of maybe a minute a day, but it's still definitely handy nonetheless! After 2 months, that's an hour back!

    The git log -L change is nice to see as well. Anything that makes git more filterable gets my vote.

  • WhyNotHugo 1 hour ago
    The new additions to `git add -p` seem pretty neat. Staging changes with `-p` is seriously underrated!
  • samtrack2019 2 days ago
    the new git history command seems to be useful for quick reword, altho since i use lazygit/magit i don't really see much of a problem to me
  • Rover222 1 hour ago
    I do almost no direct git work myself these days. Using claude in Conductor. Working on a team. I'll tell claude what do do in git sometimes, but there doesn't seem to be much need to do it myself anymore, even with complicated rebases, reflogs, etc.