我回滾到以前提交使用git checkout "commit number1"
。然後我沒有意識到我是在提交而不是在任何分支,所以我在這裏做了修改,並在"commit number1"
提交了代碼。 現在我切換到功能分支。 feature/branch1
,我看不到任何代碼。 如果我切換回"commit Number1"
,我也沒有看到代碼。 我離開了什麼?如何從git上丟失的提交中恢復代碼?
$ git checkout 49da8b4d431
Note: checking out '49da8b4d431'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
我該如何恢復代碼?我的代碼去了哪裏?
git從原點拉你想要的分支 –
下面是你需要做什麼的完整描述。 http://stackoverflow.com/questions/34519665/how-to-move-head-back-to-a-previous-location-detached-head/34519716#34519716 – CodeWizard