Sync DATAMIMIC Project with a Git Branch¶
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
Currently, Git branch synchronization is only available via API and cannot be performed through the DATAMIMIC UI.
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 confirming the operation
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
API Response Examples¶
Successful Response¶
1 2 3 4 5 6 |
|
Error Responses¶
Authentication Failed¶
1 2 3 4 5 6 |
|
Project Not Found or Not a Git Project¶
1 2 3 4 5 6 |
|
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 and the project is configured as a Git project
- 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_docs
for interactive API documentation - Refer to the Project Access Token guide for authentication troubleshooting