Under-the-hood tweaks: Git goes for speed and user experience in 2.31 release


After a quick update to keep installations secure last week, the team behind version control system git has now pushed feature release 2.31 into the open, providing devs with a range of new options and under-the-hood improvements to speed up their workflow.

Amongst other things, git maintenance has learned a few more tricks and should work on systems not normally equipped with cron for scheduling (such as Microsoft Windows). The maintenance capability was described in the 2.30 release notes as “an extended big brother of git gc” and is meant to optimise repository data to speed up other commands and reduce the storage needed. A newly added pack-refs task, for example, collects loose reference files into a single one, so that operations that need to iterate across references can save time.

Devs who find themselves regularly gravitating towards the git range-diff command but who would like something to only show one side of the compared range can start memorising the –(left|right)-only option. The tool is also able to understand “<rev>^!” and “<rev>^-<n>” descriptors when denoting a commit range. Earlier versions had trouble with anything that differed from the “..” notation.

Starting in v2.31, git mergetool can be instructed to prepare base, local, and remote versions with unconflicted parts resolved, while the worktree list annotates prunable attributes. Other than that, the git team fitted the bundle directive with a –stdin option so that devs can feed in their references through the standard input, and a –deduplicate option in ls-files should help avoid confusion by removing entries stemming from unmerged indices. 

Users should be able to feel a speedup when removing multiple branches and tags, since the procedures involved utilise a different API than before. Tweaks in git grep should have a similar effect, though this is mostly down to the command being limited to sparse checkout paths in the current iteration. 

Additional acceleration was achieved by the introduction of an on-disk file to record the reverse index for packdata which is meant to be helpful when sending objects to push or fetch. Speaking of fetch, the command now knows the –atomic option present in push, meaning ref updates can automatically be handled in an all-or-none manner.

The git team has also been busy continuing its preparations to make the switch to a new default branch name by adjusting tests to handle different names and fixing the tool’s behaviour when an empty repo is cloned. The team is also retiring more names containing “SHA1”, as it continues to transition to using SHA-256 hashes. 

A full list of changes can be found in the official announcement.