Git-如何获取本地更改而不是远程

时间:2018-06-28 09:07:28

标签: git bitbucket

我是git的新手,我对脚本进行了一些更改,然后提交并推送到我的bitbucket帐户。当我尝试将较新的脚本版本上传到服务器时,出现以下错误:

error: Your local changes to the following files would be overwritten by merge:
web_app.py
Please, commit your changes or stash them before you can merge.
Aborting

任何人都可以告诉我如何在服务器上运行该版本,并获取在位桶上固定的版本吗?

到目前为止,我已经尝试过:git reset myfile.py 然后git pull,但是,我遇到了相同的错误

1 个答案:

答案 0 :(得分:3)

删除本地修改

您希望git checkout .删除本地修改,并希望git pull下拉新修改。

请注意,这将删除所有本地修改,因此,如果您只想做1个文件,请检查此内容:

Undo working copy modifications of one file in Git?

保存并重新应用本地修改

如果要保存本地修改,但要撤消更改,可以执行以下操作:

git stash save // To save the local mods in the stash
git pull // To pull down remote mods
git stash pop // To put back the local modifications

请注意,如果您在文件中更改了相同的行,则可能需要解决冲突。