Configuring Git in a Coder Workspace
Last updated: June 25, 2026
When working in a Coder workspace, it's essential to configure Git correctly to ensure your commits are attributed to the appropriate name and email. This is particularly important when collaborating across multiple projects or teams.
Setting Git Commit Name and Email
To control the name and email used in Git commits within a Coder workspace, you can define the following environment variables:
-
GIT_AUTHOR_NAME: Specifies the author's name for the commit. -
GIT_AUTHOR_EMAIL: Specifies the author's email address for the commit. -
GIT_COMMITTER_NAME: Specifies the committer's name (often the same as the author). -
GIT_COMMITTER_EMAIL: Specifies the committer's email address.
By setting these variables, Git will automatically use the specified values for commits made from the workspace, eliminating the need to configure these settings manually for each repository.
Options for Configuring Git
There are several methods to configure these settings in a Coder workspace:
Manual Configuration
To manually set these environment variables in your shell configuration file (e.g., .bashrc or .zshrc):
# Add these lines to your shell configuration file
export GIT_AUTHOR_NAME="Your Name"
export GIT_AUTHOR_EMAIL="your.email@example.com"
export GIT_COMMITTER_NAME="Your Name"
export GIT_COMMITTER_EMAIL="your.email@example.com"
After adding these lines, reload your shell configuration:
source ~/.bashrc # or source ~/.zshrc
Using the Git Configuration Terraform Module
If you manage your Coder environment with Terraform, you can use the Git Configuration Terraform module. This module simplifies setting up Git configuration in your workspaces by automating the process of defining the necessary environment variables.
To use the module, add it to your Terraform configuration and specify the desired Git commit name and email. The module handles the rest, ensuring that your workspaces are pre-configured with the appropriate settings when they are created.
module "git_config" {
source = "coder.com/modules/git-config"
version = "1.0.0"
git_author_name = "Your Name"
git_author_email = "your.email@example.com"
git_committer_name = "Your Name"
git_committer_email = "your.email@example.com"
}
Apply your Terraform configuration to provision workspaces with the correct Git settings.
Using Coder’s Dotfiles Feature
Coder offers a dotfiles feature that allows you to automatically apply custom configurations, such as Git settings, to all your workspaces. By storing your dotfiles in a Git repository, you can ensure that your preferred configurations are applied every time a workspace is created.
How to Use Dotfiles for Git Configuration
-
Create or update your dotfiles repository. For Git configuration, include the following in your
.gitconfigfile:[user] name = Your Name email = your.email@example.com -
In your Coder dashboard, navigate to your user settings and specify the URL of your dotfiles repository in the Dotfiles section.
-
Create a new workspace. Coder will automatically clone your dotfiles repository and apply the configurations during the workspace initialization process.
Using dotfiles is a convenient way to maintain consistency across multiple workspaces without requiring manual setup or additional Terraform configuration.
Setup Script Support
To further customize your workspace, you can include a setup script in your dotfiles repository. Coder supports the following script files, executed in the specified order:
install.shinstallbootstrap.shbootstrapscript/bootstrapsetup.shsetupscript/setup
Coder will execute the first matching script found. Ensure that the script is executable; otherwise, the setup will fail. To make the script executable, run:
cd
chmod +x
git commit -m "Make executable"
git push
For more details, refer to the Coder documentation on dotfiles.
Additional Notes
Customizing your Git configuration in Coder workspaces ensures that all your commits are correctly attributed and consistent across projects. Whether you configure these settings manually, use the Terraform module, or leverage Coder’s dotfiles feature, this process can significantly streamline your development workflow.
For more details, check out the Coder Documentation.