Skip to content

Cursor’s agent handles the version-control work around a shared codebase: it drafts commit messages from the staged diff, resolves merge conflicts by reading both branches, writes pull request descriptions, and pre-reviews a teammate’s pull request. Git stays the record of truth, and tests plus git show --remerge-diff prove what the agent changed.

This page is for a developer who has Cursor installed and now works in a repository other people also push to. It is 5 p.m. on a Friday. You merge main into your feature branch before the release and hit a conflict in a file two colleagues changed this week. Their commit messages say “wip” and “fixes”, a teammate’s 600-line pull request has waited two days for review, and you do not have time to read either line by line.

What you get from agent-driven version control in Cursor

Section titled “What you get from agent-driven version control in Cursor”
  • A safe git baseline, so no agent action can cost you work you have not committed
  • A commit-message prompt that follows your team’s convention and describes only what is staged
  • A merge-conflict prompt that keeps both sides’ intent, plus two git commands that show exactly what the resolution changed
  • A pull request prompt that produces a description a reviewer can act on
  • A review prompt for someone else’s pull request that tells you where to look instead of reading every line
  • A clear split between what you check, what CI checks, and what Bugbot checks

Team-wide configuration (shared project rules, MCP servers, and skills) is covered in team collaboration in Cursor. This page is about the daily git loop.

Set a safe git baseline before the agent touches history

Section titled “Set a safe git baseline before the agent touches history”

Cursor’s agent runs git in its terminal like any other shell command, subject to the run mode you chose (Auto-review, Allowlist or Run Everything; Cursor’s docs, checked 2026-10-12). That makes it fast and also means a wrong git checkout --theirs . runs as readily as a right one. Put the safety net in place first.

  1. Start every agent task from a clean tree. Commit or stash what you have; -u also stashes untracked files, so nothing new is left behind in the tree:

    Terminal window
    git status --short
    git stash push -u -m "before agent task"
  2. Work on a branch, never on main. For a task you want isolated from your own editor, use a Cursor worktree, which lets the agent work in a separate git checkout.

  3. Write the git rules the agent must follow into your project rules (or into AGENTS.md, which Cursor also reads) so the agent has them in context: never force-push, never rewrite history that is already on the remote, never commit files matching .env*, and stop to ask before git reset --hard.

  4. Keep pushing a human step for now. Let the agent commit locally, and push after you have looked at the checks described below.

Write commit messages from the staged diff

Section titled “Write commit messages from the staged diff”

A commit message is the only context a teammate has when they meet your change in a conflict six months from now. The agent writes good ones when you tell it to read only the staged diff and to follow your convention. Without that instruction it tends to describe the whole working tree, including edits you did not stage.

Check the result in five seconds without reading the diff again: run git diff --cached --stat and confirm that every area the message mentions appears in the file list, and nothing in the list is missing from the message.

Resolve merge conflicts without losing either side

Section titled “Resolve merge conflicts without losing either side”

Generic “fix these conflicts” requests usually end with the agent picking one side and deleting the markers. The conflict disappears and so does a colleague’s change. The prompt below forces the agent to state each side’s intent first and to stop when the two are incompatible.

  1. Start the merge and list the conflicted files:

    Terminal window
    git merge origin/main
    git diff --name-only --diff-filter=U
  2. Give the agent the prompt below with the file list pasted in.

  3. When the agent has finished, run the test suite and the type check before you commit. A resolution that compiles but fails a test has dropped behaviour.

  4. Commit the merge, then inspect only what the resolution did:

    Terminal window
    git show --remerge-diff HEAD

    --remerge-diff needs Git 2.36 or later; check with git --version. This shows the difference between the conflicted state (with its <<<<<<< markers) and what was committed, so you review the decisions, not the whole files. For a rebase instead of a merge, git range-diff origin/main ORIG_HEAD HEAD compares your commits before and after the rebase.

The “stop and ask” line matters most. It is the difference between a merge you can trust and one where the agent removed a teammate’s fix to make the markers go away.

Open a pull request that a reviewer can act on

Section titled “Open a pull request that a reviewer can act on”

A pull request description written from the diff restates the diff. A useful one states the problem, the evidence that the fix works, and where the risk is. To let the agent open the pull request itself, connect the GitHub MCP server (setup in MCP setup for Cursor) or install the GitHub CLI (gh) and sign in once. The first snippet is the remote GitHub MCP server entry for Cursor (use a personal access token); the second authenticates gh:

~/.cursor/mcp.json
{ "mcpServers": { "github": {
"url": "https://api.githubcopilot.com/mcp/",
"headers": { "Authorization": "Bearer YOUR_GITHUB_PAT" } } } }
Terminal window
gh auth login

The Evidence section is what lets a reviewer trust the change without re-running everything. The full contract for agent pull requests, including acceptance results and a risk class, is in the evidence bundle.

Review a teammate’s pull request with the agent

Section titled “Review a teammate’s pull request with the agent”

The agent is most useful in review before you read any code: it builds the mental model, points at the risky hunks, and finds missing tests. You still decide whether to approve. Fetch the pull request into a local branch first so the agent works from real files:

Terminal window
git fetch origin pull/123/head:pr-123
git diff --stat origin/main...pr-123

Read the hunks from step 2 and the missing tests from step 3, then approve or request changes. For a deeper review workflow, including one pass per concern and large refactors, see code review with Cursor.

Bugbot is Cursor’s pull request reviewer: it “reviews pull requests and identifies bugs, security issues, and code quality problems” (cursor.com/docs/bugbot, checked 2026-08-28). It runs on the forge after you push, so it catches what your local checks missed rather than replacing them. Cursor’s help pages, as summarised on 2026-08-28 and not re-verified since, also describe a .cursor/BUGBOT.md file for project-specific review guidance and a bugbot run comment that re-runs a review on demand. Setup, learned rules, and Autofix are covered on the Bugbot page.

To work through Bugbot’s findings in one pass, give the agent the comments rather than retyping them:

Split parallel work across worktrees and cloud agents

Section titled “Split parallel work across worktrees and cloud agents”

Two unrelated tasks do not have to wait for each other. A local worktree gives each agent its own checkout on your machine. A cloud agent runs in an isolated VM in the cloud and can be started from the editor or by an Automation (for example, on a new Slack message). Either way, each task ends on its own branch, ready for a pull request, and goes through the same checks. Keep the tasks independent: two agents editing the same module produce the merge conflict from the previous section, and you resolve it later with less context. Worktree setup and parallel runs are covered in checkpoints and branching.

How do you prove the agent’s git work is correct?

Section titled “How do you prove the agent’s git work is correct?”

You do not re-read every line. Each artifact has a check that answers one question, and a named person who signs off.

ArtifactCheckSigns off
Commit messagegit diff --cached --stat matches the areas the message namesAuthor
Merge resolutionTests and type check pass, then git show --remerge-diff HEAD shows each decisionAuthor
Rebasegit range-diff origin/main ORIG_HEAD HEAD shows no unintended change to your commitsAuthor
Pull requestCI green, and the Evidence section lists the commands run and their resultsAuthor, then reviewer
Review of a teammate’s pull requestYou read the risk-ranked hunks and the missing-test listHuman reviewer approves
Post-push reviewBugbot findings fixed or explainedAuthor
  • The merge “resolved” by dropping a teammate’s change. Before you commit, run git merge --abort and start again with the conflict prompt above. After you commit but before you push, git reset --hard ORIG_HEAD returns you to the pre-merge state; this discards the merge commit, so check git log -1 ORIG_HEAD first.
  • The agent committed something you did not want. Find the last good entry with git reflog, then git reset --soft HEAD@{1} (or the SHA from the reflog) to undo the commits and keep the changes staged.
  • The commit message describes unstaged work. The agent read git diff instead of git diff --cached. Re-run the commit-message prompt, which names the command explicitly.
  • A secret or .env file reached a commit. If it is not pushed, remove it with git rm --cached .env, add the pattern to .gitignore, and amend the commit. If it was pushed, rotate the secret first; rewriting history does not remove it from clones and forks.
  • The agent force-pushed a shared branch. Anyone who still has the old tip can restore it. Ask them to find it in their git reflog as <old-sha>, then push it back with git push --force-with-lease=<branch>:<bad-sha> origin <old-sha>:<branch>, where <bad-sha> is the tip the agent pushed. The lease makes the push fail if anyone has pushed since. Then add “never force-push” to your project rules, and protect the branch on the forge.
  • The agent ignores your git rules. Confirm the rules actually load in a session before you rely on them, and remember that rules apply to Agent only, not to Tab completion, Inline Edit or Bugbot PR reviews (Cursor help, checked 2026-10-12). The check is in team collaboration in Cursor.

Where to go next with Cursor team workflows

Section titled “Where to go next with Cursor team workflows”

Did this guide help you?

One tap, no sign-in.

not at all a lot