在以前的git切换分支还有回滚版本的时候使用命令checkout,但是这略微繁琐了一点,也不容区分与记忆,因此后来git就更新了两个命令:

1
2
3
4
5
6
7
8
9
$ git switch aaa # 切换到 aaa分支
$ git switch -c aaa # 创建aaa,然后切换到 aaa分支


$ git restore [--worktree] aaa # 从staged中恢复aaa到worktree
$ git restore --staged aaa # 从repo中恢复aaa到staged
$ git restore --staged --worktree aaa # 从repo中恢复aaa到staged和worktree
$ git restore --source dev aaa # 从指定commit中恢复aaa到worktree

这个更新是很早以前的事情了,但是碍于现在有时候开发git版本被统一,没有跟上导致查到命令没办法使用,所以记录一下而已,所以这篇文章的配乐也不是那么促进学习。