Answer the question
In order to leave comments, you need to log in
How to overwrite old commits in git?
The situation is as follows:
I was developing in the master branch , after which it was necessary to rollback three commits back due to their uselessness, I did this with the git checkout command . Further, I already led the development and made commits from the rollback point.
Problems arose when I decided to push the changes. Starting to throw an error:
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use
git push origin HEAD:<name-of-remote-branch>
Answer the question
In order to leave comments, you need to log in
git checkout -b tmp
git checkout master
git checkout -b master_old
git checkout master
git reset --hard COMMITHASH // последний полезный комит из мастера
git merge tmp
git branch -d tmp
git push --force origin master
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question