Skip to content

Commit 7b6f49b

Browse files
committed
docs: cloning git repositories
1 parent 956d0cb commit 7b6f49b

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Cloning Git Repositories
2+
3+
<div style="padding: 0px; margin: 0px;">
4+
<span style="vertical-align:middle;">Author: </span>
5+
<a href="https://github.com/Emyrk" style="text-decoration: none; color: inherit; margin-bottom: 0px;">
6+
<span style="vertical-align:middle;">Bruno Quaresma</span>
7+
<img src="https://avatars.githubusercontent.com/u/3165839?v=4" width="24px" height="24px" style="vertical-align:middle; margin: 0px;"/>
8+
</a>
9+
</div>
10+
August 01, 2024
11+
12+
---
13+
14+
When starting to work on a project, engineers usually need to clone a Git
15+
repository. Even though this is often a quick step, Coder can automate it to
16+
make the flow more seamless, creating workspaces ready for development and
17+
reducing onboarding time.
18+
19+
The first step to enable Coder to clone a repository is to provide
20+
authorization. This can be achieved by using the Git provider, such as GitHub,
21+
as an authentication method. If you don't know how to do that, we have written
22+
documentation to help you: [Authentication with GitHub](/admin/auth#github).
23+
24+
With the authentication in place, it is time to set up the template to use the
25+
[Git Clone module](https://registry.coder.com/modules/git-clone) from the
26+
[Coder Registry](https://registry.coder.com/) by adding it to our template's
27+
Terraform configuration.
28+
29+
```hcl
30+
module "git-clone" {
31+
source = "registry.coder.com/modules/git-clone/coder"
32+
version = "1.0.12"
33+
agent_id = coder_agent.example.id
34+
url = "https://github.com/coder/coder"
35+
}
36+
```
37+
38+
> You can edit the template using an IDE or terminal of your preference, or by
39+
> going into the [template editor UI](/templates/creating#editing-templates).
40+
41+
You can also use [template parameters](/templates/parameters) to customize the
42+
Git URL and make it dynamic for use cases where a template supports multiple
43+
projects.
44+
45+
```hcl
46+
data "coder_parameter" "git_repo" {
47+
name = "git_repo"
48+
display_name = "Git repository"
49+
default = "https://github.com/coder/coder"
50+
}
51+
52+
module "git-clone" {
53+
source = "registry.coder.com/modules/git-clone/coder"
54+
version = "1.0.12"
55+
agent_id = coder_agent.example.id
56+
url = data.coder_parameter.git_repo.value
57+
}
58+
```
59+
60+
> If you need more customization, you can read the
61+
> [Git Clone module](https://registry.coder.com/modules/git-clone) documentation
62+
> to learn more about the module.
63+
64+
Don't forget to build and publish the template changes before creating a new
65+
workspace. You can check if the repository is cloned by accessing the workspace
66+
terminal and listing the directories.

0 commit comments

Comments
 (0)