如何将通配符字符串从 bash / gnome 终端传递给 git

How to pass wildcard string to git from bash / gnome terminal

此命令适用于 git 2.30.0.windows.1 到 Windows 'command' shell.

git checkout [commit hash] -- */migrations/*

它不适用于 Mate 终端或 bash (git 2.17)。问题是它们替换了目录 */migrations/* 的当前内容(它们是空的或者没有我想从中提取它们的提交时存在的文件)。无论我使用单引号还是双引号,Mate 终端都会执行此操作。

如果我调用 Bash,然后在新命令行中添加单引号或双引号,git 表示它没有任何字面上称为 */migrations/* 的文件:

error: pathspec '*/migrations/*' did not match any files known to git

如果我一次替换一个目录,我可以获得迁移文件的内容,但是有 20 多个迁移文件夹,我想我只是错过了一些关于如何从中获取我想要的内容的知识一个 Linux 终端。谁能建议我应该做什么?

*/migrations/* 语法指的是无处 路径。 root 当前工作目录.
都不是 在 checkoutgit:

之前用 ls 命令试试这些
  • *migrations/*
  • ./*migrations/*
  • $PWD/migrations/*

如果你用 ls 得到了正确的输出,那么将它应用到 git checkout ...


测试 1

ls */tmp/*
ls: cannot access '*/tmp/*': No such file or directory

测试 2

 ls /tmp/*
 it has output ...
 it has output ...