@peccul is peccu

(love peccu '(emacs lisp cat outdoor bicycle mac linux coffee))

gitに新しいサブコマンドが追加された (ブランチ切り替え: switch, ファイルを戻す: restore)

バージョン2.23より前のgitでは下記の両方でcheckoutサブコマンドを利用していた

  • ブランチ切り替え操作
  • ファイルをコミットされていた状態に戻す操作

2.23からはそれぞれに専用のサブコマンドが割り当てられ、わかりやすくなった。

もうmacではbrew upgradeで更新でき、補完機能にも更新が反映されている。

ブランチ切り替え (git switch)

$ git switch develop
Switched to branch 'develop'
Your branch is up to date with 'origin/develop'.
$ git switch feature/my-cool-feature
Switched to branch 'feature/my-cool-feature'
Your branch is up to date with 'origin/feature/my-cool-feature'.

コミットされた状態に戻す (git restore)

  • 変更前の状態
$ git status
On branch master
nothing to commit, working tree clean
$ cat README.md
# title
  • README.mdの修正
$ echo '`git restore` has come!'>>README.md
$ cat README.md
# title
`git restore` has come!
$ git diff
diff --git a/README.md b/README.md
index 1cbadfb..d72fea0 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,2 @@
 # title
+`git restore` has come!
$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   README.md

no changes added to commit (use "git add" and/or "git commit -a")
  • git restoreで戻す
$ git restore README.md
$ git status
On branch master
nothing to commit, working tree clean
$ cat README.md
# title

参考

他にもこまごまと更新されている模様

github.blog

ついでに、Gitの用語をイラストで解説してる画像を見つけたので共有しておきます