Git-无法提取新更改-如何在本地重置所有内容并强制提取当前的远程分支?

时间:2019-01-03 20:10:20

标签: git github

我先尝试git reset --hard然后尝试git pull并收到错误消息:

git: 'credential-cache' is not a git command. See 'git --help'.
error: The following untracked working tree files would be overwritten by merge:
        .../components/../somefile.component.html
Please move or remove them before you merge.
Aborting

我不记得曾经碰过这个文件。

如何真正在本地重置所有内容并仅强制从远程拉动所有内容?

谢谢。

2 个答案:

答案 0 :(得分:1)

您可以使用以下方式将本地分支重置为远程分支

git fetch origin && git reset --hard origin/branch-name

答案 1 :(得分:0)

在重新设置后,还有更多选项可用于删除不再需要跟踪的目录和文件,如果不再需要的话。

git clean -f -d && git reset --hard