docs/current_docs/partials/cookbook/filesystems/_copy-subset-directory.mdx
The following Dagger Function accepts a Directory argument, which could reference either a directory from the local filesystem or a remote Git repository. It copies the specified directory to the /src path in a container, using a filter pattern specified at call-time to exclude specified sub-directories and files, and returns the modified container.
:::note When working with private Git repositories, ensure that SSH authentication is properly configured on your Dagger host. :::
:::note This is an example of post-call filtering with directory filters. :::
<Tabs groupId="language" queryString="sdk"> <TabItem value="go" label="Go">Examples
Copy the current host directory to /src in the container, excluding all sub-directories and files starting with dagger, and return the modified container:
<Tabs groupId="shell">
<TabItem value="System shell">
```shell
dagger -c 'copy-directory-with-exclusions . --exclude=dagger*'
```
</TabItem>
<TabItem value="Dagger Shell">
```shell title="First type 'dagger' for interactive mode."
copy-directory-with-exclusions . --exclude=dagger*
```
</TabItem>
<TabItem value="Dagger CLI">
```shell
dagger call copy-directory-with-exclusions --source=. --exclude=dagger*
```
</TabItem>
</Tabs>
Copy the public dagger/dagger GitHub repository to /src in the container, excluding all Markdown files, and list the contents of the directory:
<Tabs groupId="shell">
<TabItem value="System shell">
```shell
dagger <<EOF
copy-directory-with-exclusions https://github.com/dagger/dagger#main --exclude=*.md |
directory /src |
entries
EOF
```
</TabItem>
<TabItem value="Dagger Shell">
```shell title="First type 'dagger' for interactive mode."
copy-directory-with-exclusions https://github.com/dagger/dagger#main --exclude=*.md | directory /src | entries
```
</TabItem>
<TabItem value="Dagger CLI">
```shell
dagger call \
copy-directory-with-exclusions --source=https://github.com/dagger/dagger#main --exclude=*.md \
directory --path=/src \
entries
```
</TabItem>
</Tabs>
Copy the private user/foo GitHub repository to /src in the container, excluding all Markdown files, and list the contents of the directory:
<Tabs groupId="shell">
<TabItem value="System shell">
```shell
dagger <<EOF
copy-directory-with-exclusions ssh://[email protected]/user/foo#main --exclude=*.md |
directory /src |
entries
EOF
```
</TabItem>
<TabItem value="Dagger Shell">
```shell title="First type 'dagger' for interactive mode."
copy-directory-with-exclusions ssh://[email protected]/user/foo#main --exclude=*.md | directory /src | entries
```
</TabItem>
<TabItem value="Dagger CLI">
```shell
dagger call \
copy-directory-with-exclusions --source=ssh://[email protected]/user/foo#main --exclude=*.md \
directory --path=/src \
entries
```
</TabItem>
</Tabs>