Pressing Ctrl-C during 'git checkout <branch-name>' messes up the repository
- From
- Yuri <yuri@rawbw.com>
- Date
- Jul 15, 2023, 04:26 UTC
- Message-ID
- <fe3c68d5-124e-5a87-881a-21ad8e492f76@tsoft.com>
It stops in some intermediate state, and git still says that it is on the main branch, but 'git checkout' deletes files that were added only in the main branch,
'git reset --hard HEAD' fixes the main branch, bit now it is impossible to switch to the other branch because it says that "some files would be overwritten", which shouldn't be the case.
All operations should be atomic.
When the user presses Ctrl-C, the correct action would be to cleanly return to the initial branch.
git-2.41.0
Thanks,
Yuri