SourceTree Cloned Files Are Changed Due to Line Break Code Mismatch in VisualStudio 2013

Asked 2 years ago, Updated 2 years ago, 98 views

Install Git, SourceTree and VisualStudio on new PCs as the environment transitions take place
When I cloned from the repository, a title event occurred.
It did not occur in the previous environment.

Old Environment
 Windows Server 2012 R2 Standard  Git 2.6.1.windows.1
 SourceTree 1.9.5.0
 VisualStudio Premium 2013 Version 12.0.40629.00 Update 5
New Environment  Windows Server 2012 R2 Standard  Git 2.6.3.windows.1
 SourceTree 3.4.7
 VisualStudio Premium 2013 Version 12.0.21005.1 REL

I checked the new SourceTree clone in VisualStudio team explorer and found out
All files are subject to modification, and when comparing with unmodified files, they appear to be unchanged (no difference is displayed), but
The HEAD line feed code was LF and the local line feed code was CRLF.

Similar operations in the old environment are not subject to change.
The local file line feed code I checked in the text editor is CRLF, so
Both HEAD and local are compared as CRLFs.

I would like to compare HEAD as a CRLF just like the old environment...

In addition, during the study, it was confirmed that when cloning, only VisualStudio in the new environment would be created in LF.
 Clone an existing repository to a new folder in the old SourceTree
  →Created with CRLF
 Previous VisualStudio Team Explorer→ Connection → Local Git Repository
in
 Replicate an existing repository to a new folder
  →Created with CRLF
 Clone an existing repository to a new folder in a new environment SourceTree
  →Created with CRLF
 New VisualStudio Team Explorer → Connect → Local Git Repository
in
 Replicate an existing repository to a new folder
  → Created with LF
すべて All are cloned to the same existing repository
サーバー I don't know which new line code the file on the server is saved with, but
 All core.autocrlf that you can see in git config in the new environment is false, so is it stored in CRLF?

Probably when VisualStudio team explorer executes the git command(?)
I think the reason is that the settings are different between old and new, but I didn't know where I could check/change those settings, so I posted them.

git visual-studio sourcetree

2022-09-29 22:11

1 Answers

The git configuration files are placed in three locations, in order of priority:

  • --local;.git/config
  • --global;~/.gitconfig
  • --system;/etc/gitconfig

Since --local does not exist at the time of clone, you are looking at either the --global or --system configuration, if it is set to --global, but otherwise you are looking at --system.
This is not a big problem with UNIX operating systems, but there is no /etc in Windows in the first place, and each git refers to its own location.

The difference in behavior between SourceTree and Visual Studio is likely due to the different git used by SourceTree and Visual Studio and the --system settings referenced.
Specifically, you can use Process Monitor to track which files you accessed.In my Visual Studio, I accessed both C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\etc\gitconfig and C:\Program Files\Git\git\getcode>.However, SourceTree is unlikely to access the former.

Anyway, I don't think it's hard.

 git config --global core.autocrlf<Values you want to set >

Run --global to save the configuration and get the same result no matter which git you boot from.

All core.autocrlf that you can see in git config in the new environment is false, so

Just to be sure, be aware that SourceTree and Visual Studio are not looking at the same settings (especially for the --system configuration) only from the git command launched in git config.


2022-09-29 22:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.