Git 2.23 released with two new commands ‘git switch’ and ‘git restore’, a new tutorial, and much more!

3 min read

Last week, the team behind Git released Git 2.23 that comes with experimental commands, backward compatibility and much more. This release has received contributions from over 77 contributors out of which 26 were new.

What’s new in Git 2.23?

Experimental commands

This release comes with a new pair of experimental commands, git switch and git restore for providing a better interface for the git checkout

“Two new commands “git switch” and “git restore” are introduced to split “checking out a branch to work on advancing its history” and “checking out paths out of the index and/or a tree-ish to work on advancing the current history” out of the single “git checkout” command,” the official mail thread reads

Git checkout can be used to change branches with git checkout <branch>. In case if the user doesn’t want to switch branches, git checkout can be used to change individual files, too. These new commands aim to separate the responsibilities of git checkout into two narrower categories that is operations, which change branches and operations that change files. 

Backward compatibility 

The “–base” option of “format-patch” is now compatible with “git patch-id –stable”. 

Git fast-export/import pair

The “git fast-export/import” pair will be now used to handle commits with log messages in encoding other than UTF-8.

git clone –recurse-submodules

“git clone –recurse-submodules” has now learned to set up the submodules for ignoring commit object names that are recorded in the superproject gitlink.

git diff/grep

The pattern “git diff/grep” that is used for extracting funcname and words boundary for Rust has now been added.

git fetch” and “git pull

The commands “git fetch” and “git pull” are used to report when a fetch results in non-fast-forward updates that lets the user notice unusual situation.   

git status

With this release, the extra blank lines in “git status” output have been reduced.

Developer support

This release comes with developer support for emulating unsatisfied prerequisites in tests for ensuring that the remainder of the tests succeeds when tests with prerequisites are skipped.

A new tutorial for git-core developers

This release comes with a new tutorial that target aspiring git-core developers. This tutorial demonstrates end-to-end workflow of creating a change to the Git tree, for sending it for review, as well as making changes that are based on comments.

Bug fixes in Git 2.23

  • In the earlier version, “git worktree add” used to fail when another worktree that was connected to the same repository was corrupt. This issue has been corrected in this release.
  • An issue with the file descriptor has been fixed.
  • This release comes with an updated parameter validation.
  • The code for parsing scaled numbers out of configuration files has been made more robust and easier to follow with this release.

Few users seem to be happy about the new changes made, a user commented on HackerNews, “It’s nice to hear that there appears to be progress being made in making git’s tooling nicer and more consistent. Git’s model itself is pretty simple, but the command line tools for working with it aren’t and I feel that this fuels most of the “Git is hard” complaints.”

Few others are still skeptical about the new commands, another user commented, “On the one hand I’m happy on the new “switch” and “restore” commands. On the other hand, I wonder if they truly add any value other than the semantic distinction of functions otherwise present in checkout.”

To know more about this news in detail, read the official blog post on GitHub.

Read Next

GitHub has blocked an Iranian software developer’s account

GitHub services experienced a 41-minute disruption yesterday

iPhone can be hacked via a legit-looking malicious lightning USB cable worth $200, DefCon 27 demo shows