引入 git switch 后,git checkout 还能做什么?

问题描述

众所周知,1237363242521 一个非常重载的命令。而且我确实理解某些命令被引入分发,例如到git checkout

在我使用以下命令之前:

git switch

所以我想知道 $ git checkout <existing-branch> $ git checkout <hash> $ git checkout -b <new-branch-name> 被引入后,git switch 的剩余用途是什么?这是一个已弃用的命令吗?

解决方法

它至少是为了向后兼容而保留的。想想数百万个仍在使用 using (var dbConnection = new SqliteConnection(_connectionString)) { dbConnection.Open(); using (SqliteTransaction transaction = dbConnection.BeginTransaction()) using (SqliteCommand com = dbConnection.CreateCommand()) { com.CommandText = sql; com.Parameters.Add("@dbid",SqliteType.Integer); com.Parameters.Add("@objectName",SqliteType.Text); // ... com.Prepare(); foreach (CardScryfall _card in _cards) { com.Parameters["@dbid"].Value = GetNextDBID(); com.Parameters["@objectName"].Value = (object)_card.objectName ?? DBNull.Value; // ... _ = com.ExecuteNonQuery(); } transaction.Commit(); } } 的脚本——我们是否应该赶紧重写所有这些脚本?当然没有。

实际上,它甚至没有被弃用。 the docs 中没有任何关于弃用的内容。另一方面,git restoregit switch 的文档说“这个命令是实验性的。行为可能会改变。”