我如何强制将本地文件覆盖在git pull
我的本地仓库包含一个文件名文件名与服务器上的文件名相同。
错误: 未跟踪的工作树文件“ example. txt ” 会被合并覆盖
我如何强制将本地文件覆盖在git pull
我的本地仓库包含一个文件名文件名与服务器上的文件名相同。
错误: 未跟踪的工作树文件“ example. txt ” 会被合并覆盖
当前回答
警告,如果您在 gitignore 文件中有任何目录/ * 条目, 这样做将永久删除您的文件 。
有些答案似乎很可怕。 从发生在Lauri身上的可怕意义来看,
相反(给予 > v1.7.6):
git stash --include-untracked
git pull
稍后,您可以清理藏匿历史。
手动,一对一:
$ git stash list
stash@{0}: WIP on <branch>: ...
stash@{1}: WIP on <branch>: ...
$ git stash drop stash@{0}
$ git stash drop stash@{1}
残酷地说,所有 - 一次:
$ git stash clear
当然,如果你想回到你藏的东西:
$ git stash list
...
$ git stash apply stash@{5}
其他回答
我尝试了大部分我在这里能找到的东西,
有效的是git merge -X theirs
所需经费:
解决方案 :
获取获取与 a 具有清洁联 联 年 月 日 月 日 月 月 日 月 月 日 月 月 月 日 月 月 日 月 月 日 月 月 月 日 月 月 日 月 月 月 日 月 的 月 月 月 日 月 月 日 月 的 月 月 月 月 日 月 月 月文件 文件和目录目录目录目录忽略忽略. jutignore( )和硬重置重置至来源来源.
git stash --include-untracked
git fetch --all
git clean -fdx
git reset --hard origin/master
对于那些不喜欢的人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 pull --force
或者通过使用git stash
然后运行git pull
.