1

I have a project using github git ignore template. https://github.com/github/gitignore When I git clone this repo and didn't modify anything, git status still shows me there is a file modified. The worst thing is that even use git checkout, the file still exist with modified status.

modified:   OpenCart.gitignore

This problem will cause my git submodule does not work well. How to fix it?

Update: This is what git diff shows:

diff --git a/OpenCart.gitignore b/OpenCart.gitignore
index f317912..c673f1f 100644
--- a/OpenCart.gitignore
+++ b/OpenCart.gitignore
@@ -1,7 +1,10 @@
-.htaccess
 config.php
-download/
-image/data/
-image/cache/
-system/cache/
-system/logs/
+admin/config.php
+
+!index.html
+
+download
+image/cache/*.jpg
+image/cache/data/*
+system/cache
+system/logs

But I didn't modify this file and ls command cannot list this file.

Ciel
  • 5,551
  • 5
  • 17
  • 24
  • What is the output of `git diff`? (Can you recognize what kind of changes are present?) What is the output of `git config -l`? (Do you notice any filters or anything else unusual?) – michas Mar 16 '14 at 19:18
  • Maybe you have a smudge filter? See my edited answer below. – VonC Mar 18 '14 at 10:10

1 Answers1

0

Note that for your gitignore file to be taken into account, you should rename your OpenCart.gitignore as .gitignore.

Generally, a file "modified" on checkout is because of git config core.autocrlf being set to true.
See "git replacing LF with CRLF".


For more advanced content transformation, look for a content filter driver, a smudge script which, on checkout, would modify a file.

git config -l | grep smudge

smudge

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • what does `filter.media.smudge=git-media-smudge %f` mean? Actually it is created by github app. – Ciel Mar 18 '14 at 11:09
  • I remove it, but the problem still exist. – Ciel Mar 18 '14 at 11:11
  • @Ciel does the issue still persists if you re-clone the repo? (while making sure that `git config -l | grep smudge` is empty) – VonC Mar 18 '14 at 12:07