diff --git a/ci-tools/update-nixpkgs b/ci-tools/update-nixpkgs
index 07b00a41a45d61c14e49dae02a9d5772ce5482e2..e8ce8fbdd6d8204b4460aec2af0df6b82c0032ed 100755
--- a/ci-tools/update-nixpkgs
+++ b/ci-tools/update-nixpkgs
@@ -4,10 +4,12 @@
 set -eux -o pipefail
 
 TARGET_BRANCH="nixpkgs-upgrade-$(date +%Y-%m-%d)"
-git checkout -b "${TARGET_BRANCH}"
 
 echo '{}' > morph/grid/local/public-keys/users.nix
 nix-build -A morph -o result-before
+
+git checkout "${TARGET_BRANCH}" || git checkout -b "${TARGET_BRANCH}"
+
 update-nixpkgs
 nix-build -A morph -o result-after
 diff=$(nix --extra-experimental-features nix-command store diff-closures ./result-before/ ./result-after/)