0
我檢查了我的項目的早期版本,:混帳:使用放棄更改當前簽出的版本
$ git checkout fd4a4a1
的反應是:
Note: checking out 'fd4a4a1'.
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
HEAD is now at fd4a4a1... <original commit message>
我複製的代碼塊,但沒有改變。我現在想返回到當前分支。然而,當我跑...
git checkout myCurrentBranch
...混帳抱怨:
error: Your local changes to the following files would be overwritten by checkout:
app/.meteor/packages
app/meteo4j.js
Please, commit your changes or stash them before you can switch branches.
Aborting
我不關心這些變化。如果他們是製造的,那是無意的。是否可以強制git忽略這些更改並檢出當前分支,而不以任何方式更改我的歷史記錄?
不確定你的意思是「以任何方式改變我的歷史」。 Git將移動到相關分支,並且在您進入分離頭部狀態之前,提交歷史記錄將與該分支的始終相同。 – meagar