Git stash/whatever 每个 git 开关?

Git stash/whatever on every git switch?

我们能不能有这样一个功能,我们就叫它git switch-for-humans,这样我就忘记了stashing/switching/committing/amending/etc。 (并每次都选择其中一个)永远:

  1. 当我在分支 A 并且我想切换到我刚做的任何分支 B 时: $ git switch-for-humans B 在这一点上,我的工作树无论处于什么状态(所有 tracked/untracked/etc.files,就像它一样)都神奇地隐藏或保存在特定于分支 A
  2. 的某个存储中
  3. 我到了B分店
  4. 我做任何类型的切换
  5. 在某个时刻,通过调用“git switch-for-humans A”,我回到了 A,工作树神奇地恢复了。

这 saving/restoration 适用于每个分支,w/o 用户端的任何其他操作。

是否有一些已知的方法可以从 git 获得这种行为?..

您的 git switch-for-humans 可以包括的更简单的方法是使用 multiple working trees with git worktree.

每个工作树都是一个签出的分支,您可以在其中工作,还有 amend/commit 个文件。

每个 git switch-for-humans 只需 cd(更改目录)到正确的工作树,如果它不存在则创建它。
它甚至可以更改符号链接,以便您的项目(可能在 IDE 中打开)自动引用正确的 worktree/folder.