Verify a Git checkout from an explicit directory
Build a paste-ready command, then review its compatibility and effects before running it.
git -C <existing-checkout-path> rev-parse --show-toplevelComplete required fields to copy the generated command.
read-onlyno known side effects Compatibility
Linux + macOS + WindowsVerified for Linux, macOS, Windows using bash, zsh, powershell syntax.
Operational knowledgereview due 2026-12-08
RequirementsExisting checkoutIdentify the intended checkout first. -C selects that directory without changing the shell's current directory; it does not clone or initialize a repository.
Version supportgit Current supported releasesVerified for linux, macos, windows using bash, zsh, powershell syntax; consult compatibility notes for platform-specific differences.
Expected signals/srv/projectRepresentative successful output; values vary with the selected target and system state.
Known errorscannot change toThe selected path does not exist or is inaccessible. Check the checkout location and permissions.not a git repositoryNo usable repository was found from that path. Check whether the checkout step ran, whether .git is a valid directory or gitfile, and whether GIT_DIR or GIT_WORK_TREE overrides discovery.must be run in a work treeThis may be a bare repository. --show-toplevel requires a working tree; do not create one merely to suppress the diagnostic.
Verifygit -C {{repositoryPath}} rev-parse --show-toplevelExit code 0 and the intended checkout root. Only then inspect status or history in that same directory.Rollback noteNo rollback is needed: rev-parse reads repository metadata without changing files, commits, or the current shell directory.
Command breakdown
01gitCommandRuns the git stage of this one-liner.
02-COptionConfigures git with the -C option.
03<existing-checkout-path>ParameterA value supplied in the Fill parameters section.
04rev-parseArgumentPasses rev-parse to git.
05--show-toplevelOptionConfigures git with the --show-toplevel option.
Example input
git -C /srv/project rev-parse --show-toplevel
Example output
/srv/project
Illustrative output — exact values vary by system and data.
Runbooks
Official sources