Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

When a preview port belongs to the wrong Git worktree

Описание и применение

Инструмент worktree-port-check позволяет определить, с какого Git‑checkout запущен сервер, прослушивающий заданный порт, и выявить несоответствия.

Задача

A development server may listen on the expected port while running from a different Git checkout, causing confusion when inspecting the wrong code base.

Результат

The tool successfully identified that a server listening on port 3000 was running from a different Git checkout, allowing the developer to correct the environment.

Рабочий процесс

  • 1. Run npx --yes --package=github:Arthur031221/worktree-port-check worktree-port-check 3000 to scan port 3000.
  • 2. The tool queries lsof for TCP listeners on the port.
  • 3. For each listener, it reads the process cwd and asks Git for the checkout root and common directory.
  • 4. It compares roots and common directories to determine if the listener belongs to the same, a linked worktree, or a different repository.
  • 5. The tool reports the findings, including branch names for context.
  • 6. Exit codes indicate whether a listener belongs to another checkout (1) or if information is incomplete (4).

Доказательства

I built worktree-port-check to compare the checkout in my terminal with the current directory of every visible process listening on one TCP port.

Источник

The command asks lsof for TCP listeners on the selected port. It reads the cwd for each visible process, then asks Git for the checkout root and common directory at that path.

Источник

Exit code 1 means a visible listener belongs to another checkout. Exit code 4 means the inspection did not have enough information to reach a complete result.

Источник

  • Дата записи: 2026-10-03T21:40:46.331Z