git status shows as files modified directly after clones

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Fisheye および Crucible は除く

問題

git status shows some of the files as modified after the clone without making any local changes. Following appears when a git status is run

[user@myhost ~]$ git clone -b release/3.10.2 ssh://git@stash.myhost.com/myproj/repo.git
Cloning into 'repo'...
remote: Counting objects: 351985, done.
remote: Compressing objects: 100% (133993/133993), done.
remote: Total 351985 (delta 176642), reused 341876 (delta 168250)
Receiving objects: 100% (351985/351985), 293.39 MiB | 4.41 MiB/s, done.
Resolving deltas: 100% (176642/176642), done.
Checking connectivity... done.
[user@myhost ~]$ cd repo
[user@myhost ~]$ git status
On branch release/3.10.2
Your branch is up-to-date with 'origin/release/3.10.2'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: my-backend/configuration/config/dev1/properties-key.xml
modified: my-backend/configuration/config/dev2/properties-key.xml
modified: my-backend/configuration/config/local/properties-key.xml


no changes added to commit (use "git add" and/or "git commit -a")


原因

  1. The behavior which showing some files as modified could be related to line ending setting and multiple client used. Every operating system handles line endings in it's own way. So if you are working on repositry where in the the files are edited in multiple operating systems, you may see unexpected results.
  2. .gitattributes file added to the root of the repo. It will override individual client settings and may trigger a line ending change after the clone.

ソリューション

原因 1 の場合

You can change how Git handles line endings by git config core.autocrlf command is used to change. It takes a single argument.

git config --global core.autocrlf input
# Configure Git on <your os> to properly handle line endings

原因 2 の場合

Verify your if there any .gitattributes file that trigger line ending changes. It overrides an client's core.autocrlf setting, to ensure a consistent behavior for all users, regardless of their Git settings. 

You can find more details about .gitattributes here.


最終更新日: 2018 年 1 月 24 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.