0

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?

Community
  • 1
  • 1
leafpile
  • 143
  • 1
  • 9

1 Answers1

0

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>
CodeWizard
  • 128,036
  • 21
  • 144
  • 167