Experimental commands
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.
As for 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
The new --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.
git cherry-pick
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
.
git multi-pack-index
Two new commands have been introduced for git multi-pack-index
: expire
and repack
. 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?
Other changes
git for-each-ref
with multiple patterns have been optimized.- Commit graphs have been updated.
- The
git grep
andgit diff
rules 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
status.aheadBehind
.
For more information, read the full release notes or the blog post.
The post Git 2.23 brings experimental commands git switch and git restore appeared first on JAXenter.
Source : JAXenter