2012-05-03 2 views
0

git diff의 결과는 하나의 내 파일의 전체 내용이 제거되었다가 다시 추가되었다고 말합니다. 왜 이런거야?Git은 언제 파일이 실제로 수정되지 않았을 때 수정 된 것으로 표시합니까?

diff --git a/templates/appengine/go/app.yaml b/templates/appengine/go/app.yaml 
index 303af12..223b642 100644 
--- a/templates/appengine/go/app.yaml 
+++ b/templates/appengine/go/app.yaml 
@@ -1,13 +1,13 @@ 
-# Right now, we direct all URL requests to the Go app we are about to 
-# construct, but in the future we may add support for jQuery and Bootstrap 
-# to automatically put a nice UI on the/url. 
- 
-application: {{ app_id.downcase }} 
-version: 1 
-runtime: go 
-api_version: 3 
- 
-handlers: 
-- url: /.* 
- script: _go_app 
- 
+# Right now, we direct all URL requests to the Go app we are about to 
+# construct, but in the future we may add support for jQuery and Bootstrap 
+# to automatically put a nice UI on the/url. 
+ 
+application: {{ app_id.downcase }} 
+version: 1 
+runtime: go 
+api_version: 3 
+ 
+handlers: 
+- url: /.* 
+ script: _go_app 
+ 
+1

증명해보십시오. diff를 보여주세요. –

답변

0

한 커밋에서 제거 된 다음 다시 추가 되었기 때문에 표시됩니다. 따라서 현재 상태와 마지막 커밋 간의 차이가 변경되었습니다.

당신이 라인 엔딩을 변환 한 경우 git diff 출력의이 종류가 예상되는
+0

빠른 테스트 (git 버전 1.7.5.4)에서는 그렇지 않습니다. 시험 절차 : 'mkdir test; CD 테스트; git init; cp/etc/passwd.; git add passwd; git commit -m 'add passwd'; git rm passwd; git commit -m 'passwd 제거'; cp/etc/passwd.; git add passwd; git commit -m 'passwd를 다시 추가한다' 'git diff HEAD ^^'의 결과가 비어있다. – FooF

2

(예를 들어, LF에 결과로 시작하는 유닉스 스타일의 라인 엔딩으로 윈도우에서 실행되는 나쁘게 행동 편집기를 사용하여 ->CR LF 변환). 이는 일반적으로 원시 diff 출력에서 ​​터미널로 해독 할 수없는 공백 변경 이외의 모든 파일 행을 변경하는 일반적인 방법입니다.

git diff에 대한 옵션 -w은 공백 변경을 무시합니다. 귀하의 경우에 무엇이 git diff -w처럼 보이나요? 변경 사항이 표시되지 않으면 공백이 출력의 원인입니다.

이러한 경우에, 당신은 CR 문자 (사용 가능한 유닉스 도구를 가정) git diff 출력에 '~' 문자로 변경보고 git diff | tr '\r' '~'을 할 수 있습니다.