Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MerryChristmas's avatar

GIT: you are currently not on a branch

  1. I'm in master.

  2. I went to history git checkout 845454514231. And I made a lot of changes to the code.

  3. When I now do git commit I will get error you are currently not on a branch. Understandably.

How do I force commit these changes? I don't mind losing any past/future code. My current code is only thing that matters.

0 likes
1 reply
MerryChristmas's avatar
MerryChristmas
OP
Best Answer
Level 1
git checkout -b temp
git checkout master
git merge temp
git branch -d temp

Please or to participate in this conversation.