Git使用* filename来指定文件(Git use *filename to specify file)
在这个问题中 ,答案说我可以用*来指向文件。
这适用于git add ,但是当我尝试将它与git checkout <commit> <file>我遇到了一个问题。
第二个答案中提到的git add **/DSManger.java方法也不适用于git checkout 。
leafpile (notification *+) Dev $ git add *NewTaskActivity.java (no problem) leafpile (notification *+) Dev $ git checkout dbd1 *NewTaskActivity.java error: pathspec '*NewTaskActivity.java' did not match any file(s) known to git.为什么?
In this question, the answer said that I can use *to point to files.
This works with git add, but when I try to use this with git checkout <commit> <file> I run into a problem.
The git add **/DSManger.java method mentioned in the second answer doesn't work with git checkout either.
leafpile (notification *+) Dev $ git add *NewTaskActivity.java (no problem) leafpile (notification *+) Dev $ git checkout dbd1 *NewTaskActivity.java error: pathspec '*NewTaskActivity.java' did not match any file(s) known to git.Why?
最满意答案
当你做一个git时,它会递归地添加你提出的内容(可以像你一样使用regexp)。
但是当你结账时,你需要提供完整的路径
您需要将完整路径传递给结帐
# This is the syntax git checkout <commit> <file> # pass the full path to checkout git checkout <commit> /path/to/file/NewTaskActivity.java # checkout all files under the given folder: git checkout <commit id> -- path/to/folder/**Checking out file from different branch
# when checking out from branch you need to add the -- before the file path git checkout <branch> -- <path to file>When you do a git add it's adding recursively the content you asked (can be regexp as you did).
But when you checkout you need to supply the full path
You need to pass the full path to the checkout
# This is the syntax git checkout <commit> <file> # pass the full path to checkout git checkout <commit> /path/to/file/NewTaskActivity.java # checkout all files under the given folder: git checkout <commit id> -- path/to/folder/**Checking out file from different branch
# when checking out from branch you need to add the -- before the file path git checkout <branch> -- <path to file>更多推荐
发布评论