我如何强制在 git pull 上覆盖本地文件 ? 我的本地仓库包含一个与服务器相同的文件名文件 。
错误: 未跟踪的工作树文件“ example. txt ” 会被合并覆盖
我如何强制在 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 branch -m [branch_to_force_pull] tmp
$ git fetch
$ git checkout [branch_to_force_pull]
$ git branch -D tmp
就是这样!
此解决方案总是在运行 。
cd $GIT_ROOT_DIRECTORY
git fetch origin/$TARGET_BRANCH
git rm -rf --cached .
git reset --hard origin/TARGET_BRANCH
git clean -df
git pull origin $TARGET_BRANCH
我读过所有答案,但我在找一个命令来做这个。 这就是我所做的。在.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
您可以在您的工程基准文件夹中以文件忽略该文件 :
. jutignore( )
public/images/*
然后拉动修改,然后从您的 gitignore 文件中删除该行 。
1: 重置为上一个承诺
git reset --hard HEAD
2: 删除未跟踪的文件
git clean -f
3:拉起承诺
git pull
资料来源:
http://git-scm.com/docs/git-reset https://git-scm.com/docs/git-clean/