{"record":{"id":"24cf046012310216","repo":"pcottle/learnGitBranching","slug":"git-result-nothing","errorCode":null,"errorMessage":"git-result-nothing","messagePattern":"git-result-nothing","errorType":"exception","errorClass":"GitError","httpStatus":null,"severity":"error","filePath":"src/js/git/commands.js","lineNumber":906,"sourceCode":"\n      var args = null;\n      if (commandOptions['-b']) {\n        // the user is really trying to just make a\n        // branch and then switch to it. so first:\n        args = commandOptions['-b'].concat(generalArgs);\n        command.twoArgsImpliedHead(args, '-b');\n\n        var validId = engine.validateBranchName(args[0]);\n        engine.branch(validId, args[1]);\n        engine.checkout(validId);\n        return;\n      }\n\n      if (commandOptions['-']) {\n        // get the heads last location\n        var lastPlace = engine.HEAD.get('lastLastTarget');\n        if (!lastPlace) {\n          throw new GitError({\n            msg: intl.str('git-result-nothing')\n          });\n        }\n        engine.HEAD.set('target', lastPlace);\n        return;\n      }\n\n      if (commandOptions['-B']) {\n        args = commandOptions['-B'].concat(generalArgs);\n        command.twoArgsImpliedHead(args, '-B');\n\n        engine.forceBranch(args[0], args[1]);\n        engine.checkout(args[0]);\n        return;\n      }\n\n      command.validateArgBounds(generalArgs, 1, 1);\n","sourceCodeStart":888,"sourceCodeEnd":924,"githubUrl":"https://github.com/pcottle/learnGitBranching/blob/5b09d0ff9678cad164f5a7488a279a44f90d7256/src/js/git/commands.js#L888-L924","documentation":"`git checkout -` moves HEAD back to where it was before the last move. This error is thrown when there is no previous position recorded (HEAD.lastLastTarget is unset), so there is nothing to go 'back' to.","triggerScenarios":"Running `git checkout -` as the first HEAD-moving command (no prior checkout/switch in the session), or after history of the previous target was cleared.","commonSituations":"User dashes off `checkout -` immediately after starting a level or after `git reset` scenarios that never set a prior target.","solutions":["Use an explicit ref: `git checkout main` or `git checkout <branch>`","Perform at least one checkout/switch before using `-`","Use `git switch -` only after a prior switch has been recorded"],"exampleFix":"// before\ngit checkout -\n// after\ngit checkout main","handlingStrategy":"validation","validationCode":"if (engine.HEAD.get('lastLastTarget')) { engine.checkout('-'); } else { engine.checkout('main'); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Perform one explicit checkout before using `checkout -`","Treat `-` as history nav, not a default target","Script explicit refs instead of `-` in tests"],"tags":["git","checkout","no-history"],"backgroundTag":"git-no-previous-ref","analyzedSha":"5b09d0ff9678cad164f5a7488a279a44f90d7256","analyzedAt":"2026-08-27T13:53:49.057Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}