git:放弃对当前签出版本的更改

git:放弃对当前签出版本的更改,git,git-checkout,Git,Git Checkout,我使用以下工具签出了项目的早期版本: $ 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

我使用以下工具签出了项目的早期版本:

$ 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抱怨:

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忽略这些更改并签出我当前的分支,而不以任何方式更改我的历史记录

是的,使用
git checkout-f
来“强制”进行签出,不管它是否会破坏任何未提交的更改。

不确定“不以任何方式更改我的历史记录”是什么意思。Git将移动到有问题的分支,提交历史记录将与该分支在进入分离头状态之前的历史记录相同。
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