我如何强制将本地文件覆盖在git pull我的本地仓库包含一个文件名文件名与服务器上的文件名相同。

错误: 未跟踪的工作树文件“ example. txt ” 会被合并覆盖


当前回答

我知道一种容易和痛苦的方法:

$ git branch -m [branch_to_force_pull] tmp
$ git fetch
$ git checkout [branch_to_force_pull]
$ git branch -D tmp

就是这样!

其他回答

我也有类似的问题,我不得不这么做

git reset --hard HEAD
git clean -f
git pull

您可以在您的工程基准文件夹中以文件忽略该文件 :

. jutignore( )

public/images/*

然后拉动修改,然后从您的 gitignore 文件中删除该行 。

“我的地方变化很小,或者我的地方变化不起作用。我只想将一切重置回到原创。我知道我的地方变化都将失去。”

如果情况是这样的话:

git reset --hard
git pull

我知道一种容易和痛苦的方法:

$ git branch -m [branch_to_force_pull] tmp
$ git fetch
$ git checkout [branch_to_force_pull]
$ git branch -D tmp

就是这样!

我读了所有的答案,但我正在寻找一个命令来做到这一点。这是我所做的。在.gitconfig中添加了一个Git 化名。

[alias]
      fp = "!f(){ git fetch ${1} ${2} && git reset --hard ${1}/${2};};f"

将命令运行为

git fp origin master

等于

git fetch origin master
git reset --hard origin/master