checkout: Ensure tracking is set when not rebasing

Ensure the upstream tracking branch is set for changes that aren't being
rebased.

Change-Id: I5e1c00394f0fc45821e90935370bd47c52a8bfdb
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/111076
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Reviewed-by: Oliver Newman <olivernewman@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Oleg Filatov <olegf@google.com>
diff --git a/recipe_modules/checkout/api.py b/recipe_modules/checkout/api.py
index d6a2213..549cf6f 100644
--- a/recipe_modules/checkout/api.py
+++ b/recipe_modules/checkout/api.py
@@ -652,33 +652,35 @@
             # These remain unused if change.submitted is False.
             remote = remote_branch = None
 
+            with self.m.context(infra_steps=True):
+                # Change "https://foo.googlesource.com/bar"
+                #     to "https___foo_googlesource_com_bar".
+                remote = re.sub(r'[^\w]', '_', change.remote)
+                remote_branch = '/'.join((remote, change.branch))
+                self.m.git(
+                    'git remote add',
+                    'remote',
+                    'add',
+                    remote,
+                    change.remote,
+                )
+
+                self.m.git.fetch(
+                    remote,
+                    'refs/heads/{}'.format(change.branch),
+                    prune=False,
+                    step_name='git fetch branch',
+                )
+
+                self.m.git(
+                    'git set upstream',
+                    'branch',
+                    '--set-upstream-to={}'.format(remote_branch),
+                )
+
             if not change.submitted:
                 with self.m.context(infra_steps=True):
-                    # Change "https://foo.googlesource.com/bar"
-                    #     to "https___foo_googlesource_com_bar".
-                    remote = re.sub(r'[^\w]', '_', change.remote)
-                    remote_branch = '/'.join((remote, change.branch))
-                    self.m.git(
-                        'git remote add',
-                        'remote',
-                        'add',
-                        remote,
-                        change.remote,
-                    )
-
                     self.m.git('pre-rebase log', 'log', '--oneline', '-n', '10')
-                    self.m.git.fetch(
-                        remote,
-                        'refs/heads/{}'.format(change.branch),
-                        prune=False,
-                        step_name='git fetch branch',
-                    )
-
-                    self.m.git(
-                        'git set upstream',
-                        'branch',
-                        '--set-upstream-to={}'.format(remote_branch),
-                    )
 
             if change.submitted:
                 change.base = self.m.git.rev_parse(
diff --git a/recipe_modules/checkout/tests/git.expected/ci.json b/recipe_modules/checkout/tests/git.expected/ci.json
index 97f17df..5da868e 100644
--- a/recipe_modules/checkout/tests/git.expected/ci.json
+++ b/recipe_modules/checkout/tests/git.expected/ci.json
@@ -930,6 +930,87 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipe_modules/checkout/tests/git.expected/not_in_gerrit.json b/recipe_modules/checkout/tests/git.expected/not_in_gerrit.json
index 753fede..5dd5264 100644
--- a/recipe_modules/checkout/tests/git.expected/not_in_gerrit.json
+++ b/recipe_modules/checkout/tests/git.expected/not_in_gerrit.json
@@ -586,6 +586,51 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:0.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:0.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:0.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipe_modules/checkout/tests/git.expected/other.json b/recipe_modules/checkout/tests/git.expected/other.json
index 7118fc0..f056786 100644
--- a/recipe_modules/checkout/tests/git.expected/other.json
+++ b/recipe_modules/checkout/tests/git.expected/other.json
@@ -591,6 +591,51 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipe_modules/checkout/tests/git.expected/try.json b/recipe_modules/checkout/tests/git.expected/try.json
index dfc7e54..fb55ccd 100644
--- a/recipe_modules/checkout/tests/git.expected/try.json
+++ b/recipe_modules/checkout/tests/git.expected/try.json
@@ -1170,34 +1170,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_pigweed",
       "refs/heads/main"
@@ -1251,6 +1223,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "merge-base",
       "HEAD",
       "https___pigweed_googlesource_com_pigweed_pigweed/main"
diff --git a/recipe_modules/checkout/tests/repo.expected/ci.json b/recipe_modules/checkout/tests/repo.expected/ci.json
index 493f248..58a67bc 100644
--- a/recipe_modules/checkout/tests/repo.expected/ci.json
+++ b/recipe_modules/checkout/tests/repo.expected/ci.json
@@ -293,6 +293,51 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_manifest",
+      "https://pigweed.googlesource.com/pigweed/manifest"
+    ],
+    "cwd": "[START_DIR]/co/.repo/manifests",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_manifest",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co/.repo/manifests",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_manifest/main"
+    ],
+    "cwd": "[START_DIR]/co/.repo/manifests",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipe_modules/checkout/tests/repo.expected/feature_branches_ci.json b/recipe_modules/checkout/tests/repo.expected/feature_branches_ci.json
index 61c99f9..f2d4a06 100644
--- a/recipe_modules/checkout/tests/repo.expected/feature_branches_ci.json
+++ b/recipe_modules/checkout/tests/repo.expected/feature_branches_ci.json
@@ -739,6 +739,87 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pinned",
+      "https://pigweed.googlesource.com/pinned"
+    ],
+    "cwd": "[START_DIR]/co/pinned",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pinned",
+      "refs/heads/feature1"
+    ],
+    "cwd": "[START_DIR]/co/pinned",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pinned/feature1"
+    ],
+    "cwd": "[START_DIR]/co/pinned",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipe_modules/checkout/tests/repo.expected/feature_branches_try.json b/recipe_modules/checkout/tests/repo.expected/feature_branches_try.json
index 63f5445..cd9906b 100644
--- a/recipe_modules/checkout/tests/repo.expected/feature_branches_try.json
+++ b/recipe_modules/checkout/tests/repo.expected/feature_branches_try.json
@@ -978,34 +978,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/pigweed_path",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_name",
       "refs/heads/feature1"
@@ -1059,6 +1031,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_name/feature1"
     ],
diff --git a/recipe_modules/checkout/tests/repo.expected/feature_branches_try_multiple_features.json b/recipe_modules/checkout/tests/repo.expected/feature_branches_try_multiple_features.json
index 1b3c635..cb6b0b8 100644
--- a/recipe_modules/checkout/tests/repo.expected/feature_branches_try_multiple_features.json
+++ b/recipe_modules/checkout/tests/repo.expected/feature_branches_try_multiple_features.json
@@ -1087,34 +1087,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/pigweed_path",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:1234.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_name",
       "refs/heads/feature1"
@@ -1168,6 +1140,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_name/feature1"
     ],
@@ -1350,34 +1350,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/default_path",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply default:2345.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___default_googlesource_com_default_name",
       "refs/heads/feature2"
@@ -1431,6 +1403,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/default_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply default:2345.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___default_googlesource_com_default_name/feature2"
     ],
diff --git a/recipe_modules/checkout/tests/repo.expected/feature_branches_try_no_matching.json b/recipe_modules/checkout/tests/repo.expected/feature_branches_try_no_matching.json
index 2a69d55..f4efd96 100644
--- a/recipe_modules/checkout/tests/repo.expected/feature_branches_try_no_matching.json
+++ b/recipe_modules/checkout/tests/repo.expected/feature_branches_try_no_matching.json
@@ -996,34 +996,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/pigweed_path",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:1234.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_name",
       "refs/heads/feature1"
@@ -1077,6 +1049,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_name/feature1"
     ],
@@ -1259,34 +1259,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/default_path",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply default:2345.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___default_googlesource_com_default_name",
       "refs/heads/feature2"
@@ -1340,6 +1312,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/default_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply default:2345.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___default_googlesource_com_default_name/feature2"
     ],
diff --git a/recipe_modules/checkout/tests/repo.expected/no_trigger.json b/recipe_modules/checkout/tests/repo.expected/no_trigger.json
index 6c6d40f..d7455c5 100644
--- a/recipe_modules/checkout/tests/repo.expected/no_trigger.json
+++ b/recipe_modules/checkout/tests/repo.expected/no_trigger.json
@@ -293,6 +293,51 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_manifest",
+      "https://pigweed.googlesource.com/pigweed/manifest"
+    ],
+    "cwd": "[START_DIR]/co/.repo/manifests",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_manifest",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co/.repo/manifests",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_manifest/main"
+    ],
+    "cwd": "[START_DIR]/co/.repo/manifests",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipe_modules/checkout/tests/repo.expected/prefix.json b/recipe_modules/checkout/tests/repo.expected/prefix.json
index 4a8eea4..ec7529b 100644
--- a/recipe_modules/checkout/tests/repo.expected/prefix.json
+++ b/recipe_modules/checkout/tests/repo.expected/prefix.json
@@ -925,34 +925,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/prefix/suffix",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply foo:123456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___foo_googlesource_com_prefix_suffix",
       "refs/heads/main"
@@ -1006,6 +978,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/prefix/suffix",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply foo:123456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___foo_googlesource_com_prefix_suffix/main"
     ],
diff --git a/recipe_modules/checkout/tests/repo.expected/try-multiple-cqdeps.json b/recipe_modules/checkout/tests/repo.expected/try-multiple-cqdeps.json
index 3c00924..3e66035 100644
--- a/recipe_modules/checkout/tests/repo.expected/try-multiple-cqdeps.json
+++ b/recipe_modules/checkout/tests/repo.expected/try-multiple-cqdeps.json
@@ -1169,34 +1169,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/pigweed_path",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:1234.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_name",
       "refs/heads/main"
@@ -1250,6 +1222,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_name/main"
     ],
@@ -1432,34 +1432,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/default_path",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply default:2345.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___default_googlesource_com_default_name",
       "refs/heads/main"
@@ -1513,6 +1485,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/default_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply default:2345.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___default_googlesource_com_default_name/main"
     ],
diff --git a/recipe_modules/checkout/tests/repo.expected/try-multiple-onenotapplied.json b/recipe_modules/checkout/tests/repo.expected/try-multiple-onenotapplied.json
index 0a855dc..39346f3 100644
--- a/recipe_modules/checkout/tests/repo.expected/try-multiple-onenotapplied.json
+++ b/recipe_modules/checkout/tests/repo.expected/try-multiple-onenotapplied.json
@@ -1068,34 +1068,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/pigweed_path",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:1234.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_name",
       "refs/heads/main"
@@ -1149,6 +1121,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_name/main"
     ],
@@ -1331,34 +1331,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/default_path",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply default:2345.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___default_googlesource_com_default_name",
       "refs/heads/main"
@@ -1412,6 +1384,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/default_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply default:2345.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___default_googlesource_com_default_name/main"
     ],
diff --git a/recipe_modules/checkout/tests/repo.expected/try-multiple.json b/recipe_modules/checkout/tests/repo.expected/try-multiple.json
index 7433968..8e601e0 100644
--- a/recipe_modules/checkout/tests/repo.expected/try-multiple.json
+++ b/recipe_modules/checkout/tests/repo.expected/try-multiple.json
@@ -996,34 +996,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/pigweed_path",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:1234.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_name",
       "refs/heads/main"
@@ -1077,6 +1049,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_name/main"
     ],
@@ -1259,34 +1259,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/default_path",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply default:2345.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___default_googlesource_com_default_name",
       "refs/heads/main"
@@ -1340,6 +1312,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/default_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply default:2345.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___default_googlesource_com_default_name/main"
     ],
diff --git a/recipe_modules/checkout/tests/repo.expected/try.json b/recipe_modules/checkout/tests/repo.expected/try.json
index c1f81ba..a0bb344 100644
--- a/recipe_modules/checkout/tests/repo.expected/try.json
+++ b/recipe_modules/checkout/tests/repo.expected/try.json
@@ -925,34 +925,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/pigweed_path",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_name",
       "refs/heads/main"
@@ -1006,6 +978,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_name/main"
     ],
diff --git a/recipe_modules/checkout/tests/repo.expected/try_manifest.json b/recipe_modules/checkout/tests/repo.expected/try_manifest.json
index c748477..a9fab74 100644
--- a/recipe_modules/checkout/tests/repo.expected/try_manifest.json
+++ b/recipe_modules/checkout/tests/repo.expected/try_manifest.json
@@ -696,34 +696,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/.repo/manifests",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_manifest",
       "refs/heads/feature-not-in-manifest"
@@ -777,6 +749,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/.repo/manifests",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_manifest/feature-not-in-manifest"
     ],
diff --git a/recipe_modules/checkout/tests/submodule.expected/submodule-ci.json b/recipe_modules/checkout/tests/submodule.expected/submodule-ci.json
index 4415def..a926936 100644
--- a/recipe_modules/checkout/tests/submodule.expected/submodule-ci.json
+++ b/recipe_modules/checkout/tests/submodule.expected/submodule-ci.json
@@ -960,6 +960,87 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___x_googlesource_com_b_c_d",
+      "https://x.googlesource.com/b/c/d"
+    ],
+    "cwd": "[START_DIR]/co/b/c/d",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply x:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___x_googlesource_com_b_c_d",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co/b/c/d",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply x:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___x_googlesource_com_b_c_d/main"
+    ],
+    "cwd": "[START_DIR]/co/b/c/d",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply x:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipe_modules/checkout/tests/submodule.expected/submodule-repeated-match.json b/recipe_modules/checkout/tests/submodule.expected/submodule-repeated-match.json
index b93a1fa..4e0a001 100644
--- a/recipe_modules/checkout/tests/submodule.expected/submodule-repeated-match.json
+++ b/recipe_modules/checkout/tests/submodule.expected/submodule-repeated-match.json
@@ -1167,34 +1167,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/foo1",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply x:123456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___x_googlesource_com_foo",
       "refs/heads/main"
@@ -1248,6 +1220,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/foo1",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply x:123456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___x_googlesource_com_foo/main"
     ],
diff --git a/recipe_modules/checkout/tests/submodule.expected/submodule-try-equivalent.json b/recipe_modules/checkout/tests/submodule.expected/submodule-try-equivalent.json
index b4e0961..b9ee7ec 100644
--- a/recipe_modules/checkout/tests/submodule.expected/submodule-try-equivalent.json
+++ b/recipe_modules/checkout/tests/submodule.expected/submodule-try-equivalent.json
@@ -1199,34 +1199,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/foo",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply z:123456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___z_googlesource_com_foo",
       "refs/heads/main"
@@ -1280,6 +1252,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/foo",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply z:123456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___z_googlesource_com_foo/main"
     ],
diff --git a/recipe_modules/checkout/tests/submodule.expected/submodule-try-excluded.json b/recipe_modules/checkout/tests/submodule.expected/submodule-try-excluded.json
index 898cc5f..e71617b 100644
--- a/recipe_modules/checkout/tests/submodule.expected/submodule-try-excluded.json
+++ b/recipe_modules/checkout/tests/submodule.expected/submodule-try-excluded.json
@@ -936,6 +936,87 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipe_modules/checkout/tests/submodule.expected/submodule-try-included.json b/recipe_modules/checkout/tests/submodule.expected/submodule-try-included.json
index 21eb3a7..137b780 100644
--- a/recipe_modules/checkout/tests/submodule.expected/submodule-try-included.json
+++ b/recipe_modules/checkout/tests/submodule.expected/submodule-try-included.json
@@ -903,6 +903,87 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipe_modules/checkout/tests/submodule.expected/submodule-try-multiple-cqdeps.json b/recipe_modules/checkout/tests/submodule.expected/submodule-try-multiple-cqdeps.json
index 90bcca9..54a5bcf 100644
--- a/recipe_modules/checkout/tests/submodule.expected/submodule-try-multiple-cqdeps.json
+++ b/recipe_modules/checkout/tests/submodule.expected/submodule-try-multiple-cqdeps.json
@@ -1564,34 +1564,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:3456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_pigweed",
       "refs/heads/main"
@@ -1645,6 +1617,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:3456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_pigweed/main"
     ],
@@ -1941,34 +1941,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/foo",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply x:1234.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___x_googlesource_com_foo",
       "refs/heads/main"
@@ -2022,6 +1994,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/foo",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply x:1234.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___x_googlesource_com_foo/main"
     ],
@@ -2225,34 +2225,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/bar",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply x:2345.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___x_googlesource_com_bar",
       "refs/heads/main"
@@ -2306,6 +2278,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/bar",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply x:2345.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___x_googlesource_com_bar/main"
     ],
diff --git a/recipe_modules/checkout/tests/submodule.expected/submodule-try-multiple-one-missing-one-forbidden-cqdeps.json b/recipe_modules/checkout/tests/submodule.expected/submodule-try-multiple-one-missing-one-forbidden-cqdeps.json
index 702a276..4bdf06f 100644
--- a/recipe_modules/checkout/tests/submodule.expected/submodule-try-multiple-one-missing-one-forbidden-cqdeps.json
+++ b/recipe_modules/checkout/tests/submodule.expected/submodule-try-multiple-one-missing-one-forbidden-cqdeps.json
@@ -1663,34 +1663,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:3456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_pigweed",
       "refs/heads/main"
@@ -1744,6 +1716,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:3456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_pigweed/main"
     ],
@@ -2040,34 +2040,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/foo",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply x:1234.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___x_googlesource_com_foo",
       "refs/heads/main"
@@ -2121,6 +2093,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/foo",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply x:1234.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___x_googlesource_com_foo/main"
     ],
diff --git a/recipe_modules/checkout/tests/submodule.expected/submodule-try-multiple-one-missing.json b/recipe_modules/checkout/tests/submodule.expected/submodule-try-multiple-one-missing.json
index 8cd0c62..7a7091b 100644
--- a/recipe_modules/checkout/tests/submodule.expected/submodule-try-multiple-one-missing.json
+++ b/recipe_modules/checkout/tests/submodule.expected/submodule-try-multiple-one-missing.json
@@ -1219,34 +1219,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:3456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_pigweed",
       "refs/heads/main"
@@ -1300,6 +1272,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:3456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_pigweed/main"
     ],
@@ -1596,34 +1596,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/foo",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply x:1234.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___x_googlesource_com_foo",
       "refs/heads/main"
@@ -1677,6 +1649,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/foo",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply x:1234.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___x_googlesource_com_foo/main"
     ],
diff --git a/recipe_modules/checkout/tests/submodule.expected/submodule-try-multiple.json b/recipe_modules/checkout/tests/submodule.expected/submodule-try-multiple.json
index 8df7865..aa88867 100644
--- a/recipe_modules/checkout/tests/submodule.expected/submodule-try-multiple.json
+++ b/recipe_modules/checkout/tests/submodule.expected/submodule-try-multiple.json
@@ -1218,34 +1218,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:3456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_pigweed",
       "refs/heads/main"
@@ -1299,6 +1271,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:3456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_pigweed/main"
     ],
@@ -1595,34 +1595,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/foo",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply x:1234.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___x_googlesource_com_foo",
       "refs/heads/main"
@@ -1676,6 +1648,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/foo",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply x:1234.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___x_googlesource_com_foo/main"
     ],
@@ -1879,34 +1879,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/bar",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply x:2345.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___x_googlesource_com_bar",
       "refs/heads/main"
@@ -1960,6 +1932,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/bar",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply x:2345.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___x_googlesource_com_bar/main"
     ],
diff --git a/recipe_modules/checkout/tests/submodule.expected/submodule-try.json b/recipe_modules/checkout/tests/submodule.expected/submodule-try.json
index 812d523..ffdee7b 100644
--- a/recipe_modules/checkout/tests/submodule.expected/submodule-try.json
+++ b/recipe_modules/checkout/tests/submodule.expected/submodule-try.json
@@ -1199,34 +1199,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co/baz",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply x:123456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___x_googlesource_com_baz",
       "refs/heads/main"
@@ -1280,6 +1252,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/baz",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply x:123456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___x_googlesource_com_baz/main"
     ],
diff --git a/recipes/build.expected/basic.json b/recipes/build.expected/basic.json
index 5a90fec..7512261 100644
--- a/recipes/build.expected/basic.json
+++ b/recipes/build.expected/basic.json
@@ -930,6 +930,87 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/build.expected/skip_archive.json b/recipes/build.expected/skip_archive.json
index 9e3f212..5bcbe0f 100644
--- a/recipes/build.expected/skip_archive.json
+++ b/recipes/build.expected/skip_archive.json
@@ -930,6 +930,87 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/docs_builder.expected/docs.json b/recipes/docs_builder.expected/docs.json
index 1f1e030..ab7f156 100644
--- a/recipes/docs_builder.expected/docs.json
+++ b/recipes/docs_builder.expected/docs.json
@@ -591,6 +591,51 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/docs_builder.expected/docs_dry_run.json b/recipes/docs_builder.expected/docs_dry_run.json
index 580ace8..749ed20 100644
--- a/recipes/docs_builder.expected/docs_dry_run.json
+++ b/recipes/docs_builder.expected/docs_dry_run.json
@@ -591,6 +591,51 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/envtest.expected/environment_variables.json b/recipes/envtest.expected/environment_variables.json
index d1de83e..509bc37 100644
--- a/recipes/envtest.expected/environment_variables.json
+++ b/recipes/envtest.expected/environment_variables.json
@@ -591,6 +591,51 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/envtest.expected/fail.json b/recipes/envtest.expected/fail.json
index cdd4d5e..d0c9fa0 100644
--- a/recipes/envtest.expected/fail.json
+++ b/recipes/envtest.expected/fail.json
@@ -930,6 +930,87 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/envtest.expected/pigweed.json b/recipes/envtest.expected/pigweed.json
index 24b6012..1b59ab0 100644
--- a/recipes/envtest.expected/pigweed.json
+++ b/recipes/envtest.expected/pigweed.json
@@ -930,6 +930,87 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/envtest.expected/windows.json b/recipes/envtest.expected/windows.json
index 184cbe4..fb05e79 100644
--- a/recipes/envtest.expected/windows.json
+++ b/recipes/envtest.expected/windows.json
@@ -930,6 +930,87 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]\\co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]\\co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]\\co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/luci_config.expected/starlark.json b/recipes/luci_config.expected/starlark.json
index d153bd6..512b9e5 100644
--- a/recipes/luci_config.expected/starlark.json
+++ b/recipes/luci_config.expected/starlark.json
@@ -1169,34 +1169,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_pigweed",
       "refs/heads/main"
@@ -1250,6 +1222,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_pigweed/main"
     ],
diff --git a/recipes/pw_presubmit.expected/sign.json b/recipes/pw_presubmit.expected/sign.json
index f808f56..dad3325 100644
--- a/recipes/pw_presubmit.expected/sign.json
+++ b/recipes/pw_presubmit.expected/sign.json
@@ -930,6 +930,87 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/pw_presubmit.expected/step.json b/recipes/pw_presubmit.expected/step.json
index ea14fe1..07af603 100644
--- a/recipes/pw_presubmit.expected/step.json
+++ b/recipes/pw_presubmit.expected/step.json
@@ -1169,34 +1169,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_pigweed",
       "refs/heads/main"
@@ -1250,6 +1222,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_pigweed/main"
     ],
diff --git a/recipes/recipes.expected/cq_try.json b/recipes/recipes.expected/cq_try.json
index 33207a9..1b39381 100644
--- a/recipes/recipes.expected/cq_try.json
+++ b/recipes/recipes.expected/cq_try.json
@@ -1169,34 +1169,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_pigweed",
       "refs/heads/main"
@@ -1250,6 +1222,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_pigweed/main"
     ],
diff --git a/recipes/run_script.expected/run_script.json b/recipes/run_script.expected/run_script.json
index 193c9b8..cce9ce5 100644
--- a/recipes/run_script.expected/run_script.json
+++ b/recipes/run_script.expected/run_script.json
@@ -591,6 +591,51 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/target_to_cipd.expected/pw-presubmit.json b/recipes/target_to_cipd.expected/pw-presubmit.json
index e6b4638..ca65baf 100644
--- a/recipes/target_to_cipd.expected/pw-presubmit.json
+++ b/recipes/target_to_cipd.expected/pw-presubmit.json
@@ -591,6 +591,51 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/target_to_cipd.expected/success.json b/recipes/target_to_cipd.expected/success.json
index 1a371c9..183f738 100644
--- a/recipes/target_to_cipd.expected/success.json
+++ b/recipes/target_to_cipd.expected/success.json
@@ -404,6 +404,87 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_manifest",
+      "https://pigweed.googlesource.com/pigweed/manifest"
+    ],
+    "cwd": "[START_DIR]/co/.repo/manifests",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_manifest",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co/.repo/manifests",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_manifest/main"
+    ],
+    "cwd": "[START_DIR]/co/.repo/manifests",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/tokendb_check.expected/addition.json b/recipes/tokendb_check.expected/addition.json
index b302e95..052aaf3 100644
--- a/recipes/tokendb_check.expected/addition.json
+++ b/recipes/tokendb_check.expected/addition.json
@@ -1294,34 +1294,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_pigweed",
       "refs/heads/main"
@@ -1375,6 +1347,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_pigweed/main"
     ],
diff --git a/recipes/tokendb_check.expected/no-change.json b/recipes/tokendb_check.expected/no-change.json
index 037c2fb..33ae8a4 100644
--- a/recipes/tokendb_check.expected/no-change.json
+++ b/recipes/tokendb_check.expected/no-change.json
@@ -1294,34 +1294,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_pigweed",
       "refs/heads/main"
@@ -1375,6 +1347,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_pigweed/main"
     ],
diff --git a/recipes/tokendb_check.expected/removal.json b/recipes/tokendb_check.expected/removal.json
index 9cc358e..abebfea 100644
--- a/recipes/tokendb_check.expected/removal.json
+++ b/recipes/tokendb_check.expected/removal.json
@@ -1294,34 +1294,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_pigweed",
       "refs/heads/main"
@@ -1375,6 +1347,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_pigweed/main"
     ],
diff --git a/recipes/tokendb_check.expected/update.json b/recipes/tokendb_check.expected/update.json
index e116e8d..a84099f 100644
--- a/recipes/tokendb_check.expected/update.json
+++ b/recipes/tokendb_check.expected/update.json
@@ -1294,34 +1294,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_pigweed",
       "refs/heads/main"
@@ -1375,6 +1347,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_pigweed/main"
     ],
diff --git a/recipes/tokendb_updater.expected/dry-run.json b/recipes/tokendb_updater.expected/dry-run.json
index e616a19..7619bbc 100644
--- a/recipes/tokendb_updater.expected/dry-run.json
+++ b/recipes/tokendb_updater.expected/dry-run.json
@@ -591,6 +591,51 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/tokendb_updater.expected/separate-repo.json b/recipes/tokendb_updater.expected/separate-repo.json
index c7962cf..b0ce47b 100644
--- a/recipes/tokendb_updater.expected/separate-repo.json
+++ b/recipes/tokendb_updater.expected/separate-repo.json
@@ -591,6 +591,51 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/tokendb_updater.expected/simple.json b/recipes/tokendb_updater.expected/simple.json
index 5819fb6..f82858b 100644
--- a/recipes/tokendb_updater.expected/simple.json
+++ b/recipes/tokendb_updater.expected/simple.json
@@ -591,6 +591,51 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/txt_roller.expected/backwards.json b/recipes/txt_roller.expected/backwards.json
index 52050e9..9370846 100644
--- a/recipes/txt_roller.expected/backwards.json
+++ b/recipes/txt_roller.expected/backwards.json
@@ -1000,6 +1000,51 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___foo_googlesource_com_foo",
+      "https://foo.googlesource.com/foo"
+    ],
+    "cwd": "[START_DIR]/project",
+    "infra_step": true,
+    "name": "checkout foo.apply foo:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___foo_googlesource_com_foo",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/project",
+    "infra_step": true,
+    "name": "checkout foo.apply foo:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___foo_googlesource_com_foo/main"
+    ],
+    "cwd": "[START_DIR]/project",
+    "infra_step": true,
+    "name": "checkout foo.apply foo:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/txt_roller.expected/no-trigger.json b/recipes/txt_roller.expected/no-trigger.json
index 33192b8..a362413 100644
--- a/recipes/txt_roller.expected/no-trigger.json
+++ b/recipes/txt_roller.expected/no-trigger.json
@@ -1000,6 +1000,51 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___foo_googlesource_com_foo",
+      "https://foo.googlesource.com/foo"
+    ],
+    "cwd": "[START_DIR]/project",
+    "infra_step": true,
+    "name": "checkout foo.apply foo:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___foo_googlesource_com_foo",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/project",
+    "infra_step": true,
+    "name": "checkout foo.apply foo:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___foo_googlesource_com_foo/main"
+    ],
+    "cwd": "[START_DIR]/project",
+    "infra_step": true,
+    "name": "checkout foo.apply foo:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/txt_roller.expected/success.json b/recipes/txt_roller.expected/success.json
index e3e75d8..3c1265e 100644
--- a/recipes/txt_roller.expected/success.json
+++ b/recipes/txt_roller.expected/success.json
@@ -1627,6 +1627,87 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___foo_googlesource_com_foo",
+      "https://foo.googlesource.com/foo"
+    ],
+    "cwd": "[START_DIR]/project",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.apply foo:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___foo_googlesource_com_foo",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/project",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.apply foo:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___foo_googlesource_com_foo/main"
+    ],
+    "cwd": "[START_DIR]/project",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.apply foo:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/update_python_versions.expected/simple.json b/recipes/update_python_versions.expected/simple.json
index a58e35f..04cba0e 100644
--- a/recipes/update_python_versions.expected/simple.json
+++ b/recipes/update_python_versions.expected/simple.json
@@ -591,6 +591,51 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/xrefs.expected/dry_run.json b/recipes/xrefs.expected/dry_run.json
index bcfff40..aedb3b8 100644
--- a/recipes/xrefs.expected/dry_run.json
+++ b/recipes/xrefs.expected/dry_run.json
@@ -591,6 +591,51 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/xrefs.expected/kythe.json b/recipes/xrefs.expected/kythe.json
index 3dfbb6f..229c647 100644
--- a/recipes/xrefs.expected/kythe.json
+++ b/recipes/xrefs.expected/kythe.json
@@ -591,6 +591,51 @@
   {
     "cmd": [
       "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rev-parse",
       "HEAD"
     ],
diff --git a/recipes/xrefs.expected/tryjob.json b/recipes/xrefs.expected/tryjob.json
index 16826bc..b8d906a 100644
--- a/recipes/xrefs.expected/tryjob.json
+++ b/recipes/xrefs.expected/tryjob.json
@@ -1169,34 +1169,6 @@
   {
     "cmd": [
       "git",
-      "log",
-      "--oneline",
-      "-n",
-      "10"
-    ],
-    "cwd": "[START_DIR]/co",
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
-    "timeout": 600.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "git",
       "fetch",
       "https___pigweed_googlesource_com_pigweed_pigweed",
       "refs/heads/main"
@@ -1250,6 +1222,34 @@
   {
     "cmd": [
       "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:123456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "rebase",
       "https___pigweed_googlesource_com_pigweed_pigweed/main"
     ],