Git消除了我的变化,我可以让他们回来

Git消除了我的变化,我可以让他们回来

问题描述:

我在分支上做了一些改动,我们称之为branch2。我切换到主分支而不提交更改。我猜这是一个禁忌,因为当我切换回分支2时,我所有的改变都消失了!如果用于mac的GitHub客户端会警告我,那肯定会很好。是否有反正我可以撤销这个动作并且得到我的变化?

I had some changes in a branch, we'll call it branch2. I switched to the master branch without committing the changes. I'm guessing this is a no-no because when I switched back to branch2 all of my change were gone! It sure would have been nice if the GitHub client for mac would have warned me. Is there anyway I can undo this action and get my changes back?

如果没有提交,那么没有任何做。虽然,这很奇怪,因为如果你的工作目录中有未提交的数据,git将不允许你切换分支(我不知道github是否适合mac)。

If it wasn't committed, then there's nothing to do. Although, this is weird because normally git won't allow you to switch branch if you have uncommitted data in your working directory (I don't know for github for mac exactly).

您总是可以检查 git reflog 以查看您是否提交了您的数据。

You can always check git reflog to see if you have committed your data.