Sync DATAMIMIC Project with a Git Branch¶
Warning
The current page still doesn't have a translation for this language.
But you can help translating it: Contributing.
This guide explains how to synchronize your DATAMIMIC project with a specific Git branch using API calls. This feature allows you to keep your project in sync with your Git repository, pulling the latest changes from any branch and overriding your DATAMIMIC project content.
Warning
This operation will overwrite all local changes in your DATAMIMIC project with the content from the specified Git branch. Make sure to save any important work before proceeding.
Note
Git synchronization is also available through the DATAMIMIC UI via a git-pull button in the editor, which syncs the repository's default branch. This API additionally allows specifying an arbitrary branch_name.
Prerequisites¶
- A DATAMIMIC project that is properly configured as a Git Project
- A Project Access Token for API authentication
- A http client tool installed on your system. We will use curl in this guide.
- Access to the Git repository and the specific branch you want to sync with
Step-by-Step Guide¶
Step 1: Create a DATAMIMIC Git Project¶
If you haven't already created a Git-connected DATAMIMIC project, follow these steps:
- Navigate to the Project View
- Click the (+) button to create a new project
- Select Git Project from the Project Wizard Options
- Select your Git provider and provide your Git repository URL and authentication details
- Complete the project creation process
For detailed instructions, refer to the Git Project creation documentation.
Step 2: Generate a Project Access Token¶
To interact with your project via API, you need a project access token:
- Navigate to your project
- Go to Settings → Tokens
- Add a new project access token
- Copy and securely store both the Project ID and the Project Access Token
If you are not familiar with project access token, we recommend you to read the Project Access Token documentation.
Step 3: Sync with Git Branch¶
Use the following API endpoint to synchronize your DATAMIMIC project with a specific Git branch:
1 2 3 4 | |
Parameters¶
{project-id}: Your DATAMIMIC project identifier{branch-name}: The Git branch name you want to sync with (e.g.,development,main,feature/new-feature){your-project-access-token}: Your project access token
Example¶
1 2 3 4 | |
Step 4: Verify Success¶
Upon successful execution, the API will return:
- HTTP Status Code:
201 Created - Response: A success message and the durable task ID
The server will:
- Clone your Git repository
- Checkout the specified branch
- Replace all files in your DATAMIMIC project with the content from the Git branch
- Create a snapshot of the updated project
Handling Long-Running Updates (503 + Polling)¶
For a non-trivial repository, the clone/checkout may not finish within the request's ~5 second window. In that case the endpoint returns 503 Service Unavailable instead of 201 Created, with code: "PROJECT_GIT_UPDATE_PENDING" and a task_id in the response. This is expected behavior, not an error — poll the following endpoint with that task_id until the update completes:
1 2 3 4 | |
Keep polling until the task's status is no longer running.
API Response Examples¶
Successful Response¶
1 2 3 4 5 6 7 | |
Error Responses¶
Authentication Failed¶
1 2 3 4 5 6 | |
Project Not Found¶
1 2 3 4 5 6 | |
Project Not Configured for Git¶
1 2 3 4 5 6 7 | |
Invalid Branch Name¶
1 2 3 4 5 6 | |
Advanced Usage¶
Environment Variables Setup¶
For easier management, you can set up environment variables:
1 2 3 4 5 6 7 8 9 10 11 | |
Best Practices¶
- Backup Important Work: Always ensure your local changes are committed to Git or backed up before syncing
- Test with Non-Production Branches: Test the sync process with development or feature branches before using it with production branches
- Verify Branch Existence: Ensure the target branch exists in your Git repository before attempting to sync
- Use Descriptive Branch Names: Use clear, descriptive branch names that follow your team's naming conventions
- Monitor API Responses: Always check the HTTP status code and response message to ensure successful operations
Troubleshooting¶
Common Issues¶
- 401 Unauthorized: Check that your project access token is valid and has the necessary permissions
- 404 Not Found: Verify that the project ID is correct
- 400 Bad Request: Verify that the project is configured as a Git project (
remote_urlandgit_repo_typeset) - 422 Unprocessable Entity: Ensure the branch name is valid and exists in your Git repository
- 500 Internal Server Error: Check your Git repository access credentials and network connectivity
Getting Help¶
- Review the DATAMIMIC External API Reference for complete API documentation
- Check your DATAMIMIC instance's
external_api_docsfor interactive API documentation - Refer to the Project Access Token guide for authentication troubleshooting