【发布时间】:2018-02-21 20:56:08
【问题描述】:
我正在尝试推送到我的 GitHub 存储库。但我收到以下错误:
Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
我认为这与 /config/config.json 文件有关。该文件在我的 .gitignore 中,但我在 GitHub 网站上手动添加了它,并删除了其中的密码。 pull 命令给了我这个错误:
The following untracked working tree files would be overwritten by merge:
config/config.json
Please move or remove them before you can merge.
但我不想删除它,因为它是 repo 中的重要文件。我在互联网上阅读我应该尝试 push -f,但这会完全从我的 repo 中删除该文件。 如何将我的下一个更改推送到其他文件,而不必担心这个 config.json 文件?
提前致谢,
埃里克
【问题讨论】:
-
提示。删除文件并拉取 ;)
-
将
config/config.json重命名为config/config.json__。然后拉并合并。之后将config/config.json__重命名为config/config.json。并承诺。 (不过用rebase比较好,但是用两个词来解释太难了)