Commit to Repo
The Commit to Repo Extension is a streamlined tool designed to automate the process of committing changes made during a pipeline run to your Git repository.
Created by:
Setup
- Install the DevOps extension in your DevOps Organization using the Get it free button.
- Navigate to your pipeline.
- Add the
commitToRepotask to your pipeline. - Ensure your pipeline has the
System.AccessTokenvariable enabled.
Support
Please visit mightora.io
Key Features
Commit To Git Repository
Overview
This task automates committing changes made during a pipeline run to your Git repository, ensuring everything is pushed automatically.
Key Features
- Automated Git Commits: Stages and commits all modifications to the Git repository.
- Selective Folder Commits: Optionally target specific folders for commits, or commit all changes.
- Secure Authentication: Uses the pipeline’s
System.AccessTokenfor authentication. - Customizable Commit Message: Specify a commit message via the task’s input parameters.
- Flexible Configuration: Set up Git configurations like user email and name.
How to Use
- Add the task to your Azure DevOps pipeline.
- Specify the commit message using the
commitMsginput. - Ensure your pipeline has the
System.AccessTokenvariable enabled. - Run the pipeline to commit and push changes to the repository.
Input Parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
commitMsg | Yes | - | The commit message for the changes |
branchName | Yes | main | The branch name to commit to |
tags | No | - | Comma-separated list of tags to add to the commit |
targetFolder | No | - | Specific folder(s) to commit changes from. Supports multiple folders separated by commas. Can be relative (e.g., docs) or absolute path (e.g., $(Build.SourcesDirectory)/wiki-output). If empty, all changes will be committed. |
createOrphanBranch | No | false | If checked, creates an orphan branch (no history) containing ONLY the specified target folders. Useful for creating branches with specific files and no connection to main repository history. Only works when targetFolder is specified. |
pushStrategy | Yes | normal | Choose how to push: Normal (standard push), Force Push (overwrites remote), or Delete and Recreate (deletes then recreates remote branch). |
Example Pipeline Usage
# Example 1: Commit all changes
- task: mightoraCommitToRepo@2
inputs:
commitMsg: "Automated commit from pipeline"
branchName: "main"
# Example 2: Commit changes from specific folder (relative path)
- task: mightoraCommitToRepo@2
inputs:
commitMsg: "Updated documentation"
branchName: "docs-update"
targetFolder: "docs"
# Example 3: Commit changes from specific folder (absolute path)
- task: mightoraCommitToRepo@2
inputs:
commitMsg: "Updated wiki output"
branchName: "wiki-update"
targetFolder: "$(Build.SourcesDirectory)/wiki-output"
# Example 4: Commit with tags
- task: mightoraCommitToRepo@2
inputs:
commitMsg: "Release version 1.0.0"
branchName: "main"
tags: "v1.0.0, release"
# Example 5: Create orphan branch with only specific folders (no history)
- task: mightoraCommitToRepo@2
inputs:
commitMsg: "Wiki documentation only"
branchName: "wiki-only"
targetFolder: "wiki-output"
createOrphanBranch: true
pushStrategy: "normal"
# Example 6: Force push to overwrite remote branch
- task: mightoraCommitToRepo@2
inputs:
commitMsg: "Updated wiki content"
branchName: "wiki-output"
targetFolder: "$(Build.SourcesDirectory)/wiki-output"
createOrphanBranch: true
pushStrategy: "force"
# Example 7: Delete and recreate branch (clean slate)
- task: mightoraCommitToRepo@2
inputs:
commitMsg: "Fresh wiki branch"
branchName: "word-output"
targetFolder: "wiki-output, docs"
createOrphanBranch: true
pushStrategy: "deleteAndRecreate"