Git 2.23 brings experimental commands git switch and git restore
It’s been a little over a month since the last update, and now Git 2.23 is here with some new features, changes, and fixes. Some new experimental commands and new additions to existing commands are just a taste of what’s new in the latest version. Let’s take a closer look at what’s changed.
Git 2.23 includes two new experimental commands designed to provide a better interface for git checkout. Their aim is to clearly define the responsibilities of
git checkout into two categories:
git switch takes care of operations that change branches and
git restore takes care of operations that change files.
When working with
git checkout, it’s now easier to change branch. So instead of
git checkout --branch (or alternatively,
git checkout -b), you can instead use
git switch --branch. There are many more examples and usage guides in the documentation, so check that out for more detailed information.
git restore, this command can be used to work out which files will change, as well as how and where they’ll change. Passing
--worktree will ensure the changes go into your working copy, whereas passing
--staged will put them in your index. Passing both will change both to the same thing. For more information, check out the
git restore documentation.
git merge –quit
--quit option is for use with
git merge. It behaves like
--abort in that it declares the merge aborted unsuccessfully, but unlike
--abort it leaves the state of your working copy (and index) untouched.
Another command that got an update is
git cherry-pick, which applies the changes from one or more commits on top of your current branch. If you’re applying a single commit, you can always cancel the cherry-pick. However, now, if you’re applying multiple commits and the application fails in the middle of the list you can run
git cherry-pick --skip where previously you would have had to run
git reset && git cherry-pick --continue.
Two new commands have been introduced for
repack breaks down the objects in your MIDX into smaller packfiles, then recreates the MIDX with the new packs. Once that’s done, running
expire will clean up references to packfiles that don’t have objects listed in the MIDX.
SEE ALSO: Software, access, and realpolitik — How should open source communities respond to the GitHub restrictions?
git for-each-refwith multiple patterns have been optimized.
- Commit graphs have been updated.
git diffrules for determining what is a valid function signature and what encloses a valid function context have been extended to cover Octave and Rust.
- Calculating whether a branch is ahead or behind of a remote branch can now be switched off by default by setting the configuration variable