Question: I'm writing a script to retrieve files from a commit under myDir directory but i can't get it to work here's the script :

```
echo "************* $commit ******************      "
        list_files = `git diff-tree --no-commit-id --name-only -r $commit | grep myDir`
        for file in $list_files
            do
                echo "File name is : $file "
        done

```

I always get an error in list\_files saying that : 

> 
> list\_files: command not found
> 
> 
>

Answer: 
Remove the space before and after = 

```
list_files = `git diff-tree

```

should be

```
list_files=`git diff-tree.....`

```

Say, if `x=10` is given as `x = 10`, then shell will think `x` is a command called with 2 arguments. Since there is no such command called `x`, it gives the error command not found.
When using your command (`diff-tree`) while `HEAD` was a commit that had `d/a` and `d/b` to list the contents of `d` in a commit that has `d/a`, `d/b`, and `d/c`, your command only gave me `d/c`. In other words, it listed the files that are not in `HEAD`'s version of the directory.

To answer your title question, this command lists the files in a given commit:

```
git ls-tree -r --name-only "$commit" "$directory"

```