r/MicrosoftFabric • • 2d ago

CI/CD GitHub integration - Undo API call

I have been creating scripts for automated deployment using the git integration. Any change to the main branch automatically triggers the update of a workspace.
I have had some scenarios though were something goes wrong and I need to reset the workspace to re-sync with what is currently in the main branch in GitHub. I can manually use the Undo button, but I want to automate this step. Is there an API for that?

3 Upvotes

2 comments sorted by

2

u/Environmental-Fun833 2d ago

Yep, there's an API for that. `POST /workspaces/{ws}/git/updateFromGit`. You'll use PreferRemote in this case.

{

"remoteCommitHash": "<from git/status>",

"workspaceHead": "<from git/status, omit on first sync>",

"conflictResolution": { "conflictResolutionType": "Workspace", "conflictResolutionPolicy": "PreferRemote" },

"options": { "allowOverrideItems": true }

}

1

u/One-Barber-264 17h ago edited 17h ago

That's the function I have been using, but it doesn't seem to revert uncommitted workspace changes. The documentation actually states

The update only affects items in the workspace that were changed in those commits. 

https://learn.microsoft.com/en-us/rest/api/fabric/core/git/update-from-git?tabs=HTTP