【问题标题】:After pushing commit to github, code changes showing wrong将提交推送到github后,代码更改显示错误
【发布时间】:2016-08-04 12:46:51
【问题描述】:

问题:这是真正的Code Difference & 在我在 github 的提交中显示@@ -1,202 +1,251 @@,因为该文件已被完全替换。我想看看 github 中代码的不同,如下图所示。

系统信息:我在 windows 8.1 中使用 sublime text 2 和 windows 7 中使用 phpdesigner 7 编辑我的代码

解决方案,我在提交之前尝试过:

  • 将编辑器中的行格式设置更改为 windows/unix/macOSx
  • 在我的 .gitattribute 中添加了* text=auto
  • 我也试过dos2unix & unix2dos 命令
  • 奇怪的是,如果我使用 vi 编辑,它可以工作。但是,我不习惯使用它。

我的 .gitattribute :

# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs     diff=csharp

# Standard to msysgit
*.doc    diff=astextplain
*.DOC    diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot  diff=astextplain
*.DOT  diff=astextplain
*.pdf  diff=astextplain
*.PDF    diff=astextplain
*.rtf    diff=astextplain
*.RTF    diff=astextplain

谢谢。

【问题讨论】:

  • 我将删除我的答案,因为它不符合您在我们的对话中指定的问题,也许这个答案可以help
  • @e.doroskevic 感谢您调查我的问题。由于我不想让其他专家误解,我可以请求您编辑我的问题以解决任何模糊问题吗?
  • @Arf 这是一个高度赞扬。我很感激,尽管我远非如此。我不完全理解这个问题,我可能推测并说你想要git diff 所做的事情之间的一些东西,但也包括行号。或许,添加一个您想要查看的简单输出示例。这应该可以帮助其他人帮助您
  • @e.doroskevic 感谢您的建议。我已经添加了一张图片。

标签: git github sublimetext2 core.autocrlf phpdesigner


【解决方案1】:

问题已解决。

我做错了什么

  • 我不是在递归模式下运行unix2dos。
  • 我不知道为什么,但我的 .gitattribute 文件是原因之一

解决方案

  • 运行find . -type f -exec unix2dos {} \;这将自动将所有文件更改为crlf/windows格式
  • 删除了我的 .gitattributes 文件

还有 TADA,一切正常

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-05-13
    • 2014-11-27
    • 1970-01-01
    • 1970-01-01
    • 2019-07-01
    • 2018-08-11
    • 2020-01-04
    • 1970-01-01
    相关资源
    最近更新 更多