无法使用'git checkout'命令忽略本地更改

无法使用'git checkout'命令忽略本地更改,git,git-merge,git-checkout,Git,Git Merge,Git Checkout,我有这个: $ git checkout -- . $ git pull Updating 4411c31..db4498d error: Your local changes to the following files would be overwritten by merge: index.js utils.js Please commit your changes or stash them before you merge. Aborting 我一直在

我有这个:

$ git checkout -- .
$ git pull
Updating 4411c31..db4498d
error: Your local changes to the following files would be overwritten by merge:
        index.js
        utils.js
Please commit your changes or stash them before you merge.
Aborting

我一直在尝试git checkout-。它一直给我同样的信息。我该如何消除这里的局部变化?我不想保留对index.js和utils.js的更改。

我最好的猜测是您的文件已经在git中暂存。这意味着要摆脱这些变化,您必须git reset HEAD。要取消显示更改,请使用git签出-。为了真正摆脱它们。如果这是不正确的,请显示git状态的结果好吗?

如果更改已经转移,您可能需要先执行git重置。如果您希望保留这些更改,请git将其隐藏或创建一个新分支git签出-b new branch,然后提交更改。更改回原始分支,然后git pull