The terminal waits. The cursor blinks. You run git checkout—and it hangs, asking for input through the TTY.
When Git needs more than just a branch name, it can prompt for credentials or confirmation. This happens when commands run in an interactive terminal, or when a script triggers a git checkout that relies on a TTY for user input. The TTY (teletypewriter) is the device file that connects your shell to standard input and output. If you’re in a CI/CD pipeline or a detached process, there’s no TTY, and the command fails or blocks.
git checkout interacts with the TTY when:
- Switching to a branch that triggers hooks needing input.
- Entering a detached HEAD state where credentials must be re-entered.
- Scripts using
-- incorrectly, causing Git to interpret arguments as prompts.
To debug, first check if your shell has an attached TTY:
tty
If it returns “not a tty,” you’re in a non-interactive environment. To work around this, you can:
- Use
GIT_TERMINAL_PROMPT=0 to disable interactive prompts. - Preload credentials via a credential helper.
- Run scripts with
ssh -t or script to force a pseudo-TTY. - Migrate from
git checkout to git switch or git restore for more explicit behavior.
In CI/CD, the TTY issue often pairs with environment isolation. Ensure your runners pass necessary variables and do not strip TTY allocation. In Docker, add -t to docker run if you truly need interactive prompts.
Most production-grade workflows avoid any TTY interaction by ensuring all inputs are scripted, all credentials cached, and git checkout calls fully deterministic. This eliminates blocking and makes build logs clean.
If git checkout and TTY logic are choking your automation, stop fighting the cursor. Use tooling that handles environment simulation, input injection, and Git state transitions without surprises.
Run it live in minutes with hoop.dev and see how painless interactive Git can be when the TTY is on your side.