1

Recently I am getting a weird git issue. Whenever I am getting pull from a remote branch it is resulting in a modified change in any existing local branch. The changes is that first file is first deleting the content and then rewrite it i.e. same change rewriting again. So I did not get how it is possible. One thing I want to mention a few time before I have got some conflicts when I was merging this branch to a upper branch so I resolved the conflict in the gitlab IDE itself and then take pull from there in my local. So after that I am getting this issue.

The main thing is that when I resolved that conflict it has committed so why it is showing as local change? Also this is not going by doing git checkout, stash or reset --hard.

I have also tried the config settings like crlf and file mode etc but no luck.

Please let me know how to get rid of this change as I do not want to commit this from my local. I also do not want to rebase as it will affect other developer. Please help.

Stack user
  • 519
  • 6
  • 19
  • The change is in one file only but if it was due to my conflict resolved from gitlab then that time I have conflict in two files. so two files should show these modified changes. – Stack user Feb 04 '20 at 05:02
  • What `git config core.autocrlf` does return? – VonC Feb 04 '20 at 05:21
  • currently it is set as input as I am working on unix system but I have tried with true and false values as well. Nothing happened. – Stack user Feb 04 '20 at 06:25
  • Please see https://stackoverflow.com/a/59644154/3700414 – Rusi Feb 04 '20 at 16:47

1 Answers1

1

Try and set git config --global core.autocrlf false

Then clone again. EOL should be specified only in .gitattributes directives.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • is there no chance or any other way without clone? – Stack user Feb 04 '20 at 07:10
  • @Stackuser cloning again is for testing if this works (you can clone in a separate folder to test). But if you really do not want to clone again, do a `git add --renormalize .` in your repo, as I mention in https://stackoverflow.com/a/47580886/6309 – VonC Feb 04 '20 at 07:14
  • Ok I will clone then but one more concern is that my collegue does not get this issue and why this suddenly happened as I am working on it from long time. – Stack user Feb 04 '20 at 07:30
  • @Stackuser Assuming your colleagues has the same OS, check the `git config -l` output for any difference between you and your colleague's setting. – VonC Feb 04 '20 at 07:34
  • Thanks I have set it false and then clone it. The issue is resolved now. but I am still wondering why I cant just set autocrlf false in my prev. clone and then change the eol somehow for that particular file. could it be possible? – Stack user Feb 04 '20 at 08:12
  • please let me know. – Stack user Feb 04 '20 at 08:17
  • Also my colleague not getting any value for autocrlf. – Stack user Feb 04 '20 at 08:22
  • @Stackuser Yes, in your previous local clone repo, a `git add --renormalize .` would have forced the files to be with their original eol style, as I explain in https://stackoverflow.com/a/47580886/6309 – VonC Feb 04 '20 at 08:22
  • @Stackuser It is best to always set a `git config --global core.autocrlf` to `false` in order to avoid any surprise. – VonC Feb 04 '20 at 08:23
  • but it will be go as a commit? – Stack user Feb 04 '20 at 08:23
  • @Stackuser Do a git status after your `git add --renormalize .` (assuming you did `git config --global core.autocrlf false` first): those files should not appear modified anymore. That means no commit, which means nobody is affected. – VonC Feb 04 '20 at 08:24
  • sorry getting error : error: unknown option `renormalize' – Stack user Feb 04 '20 at 08:25
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/207156/discussion-between-vonc-and-stack-user). – VonC Feb 04 '20 at 08:25