> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: Sample Flows

## Article: Sample Flows

## Article Link: https://dev.wix.com/docs/api-reference/account-level/git-codestore/sample-flows.md

## Article Content:

# Git Code Store Projects: Sample Flows

This article presents possible use cases and corresponding sample flows that you can support. It provides a useful starting point as you plan your implementation. The flows assume you already have the managed project ID and the authenticated user context described in the introduction.

## Download a project's code

To inspect the files from a branch or a specific revision locally:

1. Call [Generate Git Code Store Project Download Url](https://dev.wix.com/docs/api-reference/account-level/git-codestore/generate-git-code-store-project-download-url.md) with the managed project ID and branch name. Optionally provide a full revision ID reachable from that branch.
2. Download the ZIP with HTTP GET using the returned `downloadUrl` before it expires. See [Transfer Repository Archives](https://dev.wix.com/docs/api-reference/account-level/git-codestore/transfer-repository-archives.md) for the HTTP request format.
3. Retain the returned `revision.id` and `branchName` if you intend to update the same branch.

## Update a project's code

To edit a downloaded snapshot and commit the complete replacement tree:

1. Download the branch's current code using the flow above. Edit the files and create a ZIP containing the complete replacement tree, with paths relative to the repository root. Preserve Unix file types and permission bits so executable files and symbolic links survive the transfer.
2. Call [Generate Git Code Store Project Upload Url](https://dev.wix.com/docs/api-reference/account-level/git-codestore/generate-git-code-store-project-upload-url.md) with the same managed project ID.
3. PUT the ZIP bytes to the returned `uploadUrl`, using all returned `headers`. Wait for the PUT to succeed. The repository has not changed yet.
4. Call [Commit Git Code Store Project Upload](https://dev.wix.com/docs/api-reference/account-level/git-codestore/commit-git-code-store-project-upload.md) with the same managed project ID, the returned `uploadId`, the downloaded `branchName`, and the downloaded `revision.id` as `expectedHeadRevisionId`. Supply a commit message and the author's name and email.
5. Read the returned revision. `changed: true` means a new commit was created. `changed: false` means the tree was unchanged and no commit was created.

If the expected head is stale, the commit fails with `GIT_HEAD_COMMIT_MISMATCH`. Download the current branch, reconcile your changes, and upload a new ZIP before retrying with the new revision ID. A concurrent push can also fail with `GIT_PUSH_CONFLICT`.

## Recover from an interrupted commit

A timeout does not tell you whether the commit reached the repository. Before retrying:

1. Call [Generate Git Code Store Project Download Url](https://dev.wix.com/docs/api-reference/account-level/git-codestore/generate-git-code-store-project-download-url.md) for the same managed project and branch, omitting `revisionId`. The returned `revision.id` identifies the current branch head at the time of that request.
2. Download the returned ZIP and compare its contents with your intended changes. A different revision ID alone does not prove that your request succeeded. Another caller may have committed.
3. If the current tree contains the intended result, no replacement commit is needed. Otherwise, reconcile your changes with that tree, upload a new complete ZIP, and commit using the newly downloaded revision ID as `expectedHeadRevisionId`. A later concurrent change can still cause a conflict.

Setting `force: true` deliberately bypasses the expected-head check and can replace intervening changes. Omit it for the normal edit and recovery flows.

If committing returns `REPOSITORY_UPLOAD_NOT_FOUND`, the upload may be missing, expired, associated with a different managed project, or replaced while it was being read. Generate a new upload URL for the correct project, upload the ZIP again, and retry with an appropriate expected head.