我如何强制将本地文件覆盖在git pull
我的本地仓库包含一个文件名文件名与服务器上的文件名相同。
错误: 未跟踪的工作树文件“ example. txt ” 会被合并覆盖
我如何强制将本地文件覆盖在git pull
我的本地仓库包含一个文件名文件名与服务器上的文件名相同。
错误: 未跟踪的工作树文件“ example. txt ” 会被合并覆盖
当前回答
看起来最好的办法是首先做到:
git clean
删除所有未跟踪的文件,然后继续按常规git pull
...
其他回答
如果您正在制定您的代码, 发现新的更改是一个巨大的错误或意外, 您可以简单地使用其他选项, 比如 :
git restore .
。指目录中的所有文件。
看起来最好的办法是首先做到:
git clean
删除所有未跟踪的文件,然后继续按常规git pull
...
比较容易的方式是:
git checkout --theirs /path/to/file.extension
git pull origin master
这将用 Git 上的文件覆盖您的本地文件
对于那些不喜欢的人reset
我喜欢这个方法:
git checkout branchname # go to your branch
git fetch origin branchname # fetch the remote
git checkout -b backup # optionally, mark your remote as a backup
git branch -f branchname origin/branchname # force your local branch to be equal to the fetched origin/branchname
“我的地方变化很小,或者我的地方变化不起作用。我只想将一切重置回到原创。我知道我的地方变化都将失去。”
如果情况是这样的话:
git reset --hard
git pull