Work Hours
Monday to Friday: 8am – 6pm
Weekend: 10am – 2pm
Have you ever dropped changes (usually on the first commit) into a repository with a disconnected branch?
To me, yes. Several times. It then disappears what we have commited after switching to the branch.
How can this be undone? Very simply. In nature and git nothing is lost 🙂
We open the console and type the command:
git reflog
We get a list of recent operations. In red I marked the commit of the disconnected code.
We find the hash of our commit and call the command:
git reset --hard 7f97bf2
And that’s it. We can now make a push to the server. When we call up the reflog again, we’ll see that our code has already been merged into the current branch.