#2 Git 命令

2021-08-04

看到有篇文章说是 git “新增”了 switch 和 restore 两个命令,仔细一看,原来就是 2019 年就引入了的两个命令,不过我确实没有用过。

这里重新整理一下现在 git 的命令。

git version
git version 2.30.2

apt list --installed | grep ^git
git-doc/hirsute,hirsute,now 1:2.30.2-1ubuntu1 all [已安装]
git-extras/hirsute,hirsute,now 6.1.0-1 all [已安装]
git-flow/hirsute,hirsute,now 1.12.3-1 all [已安装]
git-man/hirsute,hirsute,now 1:2.30.2-1ubuntu1 all [已安装,自动]
git-svn/hirsute,hirsute,now 1:2.30.2-1ubuntu1 all [已安装]
git/hirsute,now 1:2.30.2-1ubuntu1 amd64 [已安装]
gitg/hirsute,now 3.32.1-1 amd64 [已安装]
gitk/hirsute,hirsute,now 1:2.30.2-1ubuntu1 all [已安装]

#1 Git 补丁包

2018-08-01
  • git diff 对应 diff 命令
  • git apply 对应 patch 命令
git diff v1.2.1 v1.2.2 > v1.2.1_v1.2.2.patch

git apply --check v1.2.1_v1.2.2.patch

git apply -v --whitespace=warn v1.2.1_v1.2.2.patch

有部分文档中说 git applypatch 在一些细节上实现不一致,需要留意。但我轻量级使用,没有遇到过什么问题。