Saint Robson
Saint Robson

Reputation: 5525

Git Checkout Cannot Back to Master

I'm checking my code because there's a bug that I need to trace back into few days ago by using this command :

git checkout 35edc63
git checkout 3d09bbc
git checkout e450a0a

basically, I'm jumping from one commit into another commit to check which commit cause the bug.

once I found the bug, I cannot go back to the master commit, I tried to use this command to back to the master :

git checkout master

and here's the error message :

error: Entry 'error_log' would be overwritten by merge. Cannot merge.

I tried to delete the 'error_log' file as well, but still cannot go back to master. what did I do wrong? thank you.

Upvotes: 0

Views: 223

Answers (2)

Mohammad Nimer
Mohammad Nimer

Reputation: 1

try this command

git reset HEAD --hard

using this command it'll reset to your latest commits on the same branch, if you need the latest on master do the following command on the resetted branch

git pull origin master

Upvotes: 0

Tim Biegeleisen
Tim Biegeleisen

Reputation: 520898

Do a hard reset to the last detached commit you were on, then just checkout the master branch from there:

git reset --hard e450a0a
git checkout master

If there be any files still sitting around in your working directory, then do this:

git clean -f -d

Disclaimer: This answer assumes that you don't want to retain any changes you might have made. So it is appropriate as a safe escape from looking around other commits, but it is another story if you want to keep any work you have done.

Upvotes: 1

Related Questions