Git Merge --allow-unrelated-histories: When and How to Use It - Fix Detached HEAD During Git Rebase-Solving the Externally-Managed Environment Problem in pip

Final checklist
- Confirm that the same symptom is gone after a restart or refresh.
- Keep the smallest working change and undo temporary diagnostic settings.