2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Windows&SourceTreeでの開発環境で、ブランチの変更を行うと改行コードがCRLFになってしまう

Last updated at Posted at 2022-03-11

Windows10環境でSourceTreeを利用しています。
gitで管理しているファイルの改行コードは「LF」なのに、ブランチ変更でファイルの改行コードがCRLFになってしまう事に気が付いた。
なんかおかしい。と思いSourceTreeのgit config見てみた。

git config

C:\Users\{ユーザー名}> cd C:\Users\{ユーザー名}\AppData\Local\Atlassian\SourceTree\git_local\bin
C:\Users\{ユーザー名}\AppData\Local\Atlassian\SourceTree\git_local\bin> git config --system -l

あれ?

~中略
core.autocrlf=true
~中略

読んで字のごとく「自動CRLF=true」になってしまっているじゃないか!?

解決方法

globalとsystemの「core.autocrlf」を「false」にする

global

C:\Users\{ユーザー名}\AppData\Local\Atlassian\SourceTree\git_local\bin> git config --global core.autocrlf false
↓
C:\Users\{ユーザー名}\AppData\Local\Atlassian\SourceTree\git_local\bin> git config --global -l
~中略
core.autocrlf=false
~中略

system

C:\Users\{ユーザー名}\AppData\Local\Atlassian\SourceTree\git_local\bin> git config --system core.autocrlf false
↓
C:\Users\{ユーザー名}\AppData\Local\Atlassian\SourceTree\git_local\bin> git config --system -l
~中略
core.autocrlf=false
~中略

一件落着。

2
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?