【问题标题】:Ignored files in Git would be overwritten by mergeGit 中忽略的文件将被合并覆盖
【发布时间】:2018-12-26 22:51:04
【问题描述】:

当我拉入我的服务器时,这是我收到的消息:

错误:您对以下文件的本地更改将被覆盖 通过合并: css/custom.css images/logo.png 请在合并之前提交您的更改或存储它们。

但是这 2 个文件在我的 .gitignore 中被忽略,如下所示:

# general
inc/config.php
css/custom.css
favicon.ico

我做错了什么? 提前致谢!

【问题讨论】:

  • 一开始,您将这些文件提交到 repo,之后 git 跟踪这些文件,如果这是您的场景,您必须将它们添加到 git ignore 文件中 git rm --cached 将工作

标签: git merge gitignore ignore pull


【解决方案1】:

1) 一些团队成员已经提交了这些文件,因此当您进行 git pull 时,您将恢复那些已提交的文件更改,并且在您的下一次提交中,这些文件将被视为被忽略的文件。

2) 在合并之前,您需要:

  • 提交您的修改: git add path/to/modified-file 然后git commit -m "commit message" 最后git pull

或者

  • 保存您的修改: git stash 然后 git pull 并再次使用git stash pop 恢复您的修改

【讨论】:

  • 谢谢,帮了大忙!
猜你喜欢
  • 2017-04-08
  • 2015-02-11
  • 2016-05-07
  • 1970-01-01
  • 2013-10-04
  • 2013-02-20
  • 2022-09-23
  • 1970-01-01
相关资源
最近更新 更多