2011-12-07 3 views
3

내 .gitignore 파일이 예기치 않게 작동하는 것 같습니다. 다음은 그 예이다 :.gitignore는 공백입니까?

예상대로
[email protected]:~$ mkdir foo 
[email protected]:~$ cd foo/ 
[email protected]:~/foo$ touch bar.txt 
[email protected]:~/foo$ git init 
Initialized empty Git repository in /home/pon2/foo/.git/ 
[email protected]:~/foo$ git status 
# On branch master 
# 
# Initial commit 
# 
# Untracked files: 
# (use "git add <file>..." to include in what will be committed) 
# 
#  bar.txt 
nothing added to commit but untracked files present (use "git add" to track) 

, bar.txt라는이 같은 추적되지 나타납니다 :

은 내가 무시하려는 파일 bar.txt라는와 새로운 환매 특약 foo는합니다. 그래서 .txts를 무시하는 자식에게,하지만 난 실수로 일부 후행 공백 추가 : 나는 REPO 상태를 확인할 때 이제

[email protected]:~/foo$ echo "*.txt " > .gitignore 

을, 자식은 bar.txt라는 무시하지 않습니다 : 무슨 무슨

[email protected]:~/foo$ git status 
# On branch master 
# 
# Initial commit 
# 
# Untracked files: 
# (use "git add <file>..." to include in what will be committed) 
# 
#  .gitignore 
#  bar.txt 
nothing added to commit but untracked files present (use "git add" to track) 

에?

+0

질문 *으로 질문하는 한 자신 만의 질문을 할 수 있습니다. http://meta.stackexchange.com/questions/12513/should-i-not -answer-my-own-questions 그렇지 않으면 블로그 게시물 일 뿐이며 여기에 속하지 않습니다. –

+1

gitignore 맨 페이지에서 힘내 개발자에게이 패치를 보내라. – jamessan

+0

@GregHewgill, 고마워, 고정. – wvoq

답변

2

.gitignore는 공백입니다. 후행 공백을 포함하면 git이 파일을 인식하지 못합니다.

[email protected]:~/foo$ echo "*.txt" > .gitignore 

문제는 해결 :

[email protected]:~/foo$ git status 
# On branch master 
# 
# Initial commit 
# 
# Untracked files: 
# (use "git add <file>..." to include in what will be committed) 
# 
#  .gitignore 
nothing added to commit but untracked files present (use "git add" to track) 
[email protected]:~/foo$ 
+1

"b.txt"파일을 만들었고 origin .gitignore에서이 파일을 올바르게 무시했습니다. 당신이 뭔가 다른 것을 기대하고 있었다면 정확히 무엇을 기대 했습니까? –

+1

@CharlesBailey, 후행 공백이있는 파일 이름은 일종의 병적 인 엣지 경우처럼 보입니다. 실수로 내 후위 공백을 내 .gitignore에 넣으면 git이 올바른 일을하고 무시할 것으로 기대합니다. 그것이 당신의 견해에서 옳은 것인가하는 것은 당신에게 달렸지 만, 나는 그것이 매우 혼란스러운 행동이라는 것을 적어도 인식 할 수 있기를 바랍니다. 나는 이것에 대한 어떠한 문서도 보지 못했고 그래서 나는 그것을 혼란스럽게 생각한 사람들을위한 빵 부스러기로 올려 놓았다. – wvoq

+0

공백이있는 파일 이름은 대개 가장 피해야한다는 데 동의하지만 명시 적으로 무시하려는 경우 허용해야합니다. .gitignore에 대한 변경 사항을 확인하고 싶다면, 커밋하기 전에'git diff --check'을 사용하는 것을 고려해야합니다. (또는'git log -p --check'를 사용하면 나쁜 이전 버전을 찾을 수 있습니다.) –

0

이 자식 2.0에서 변경 우리가 해결되면

[email protected]:~/foo$ echo "*.txt " > .gitignore 

:

이 라인에서 후행 공백이있다. release notes에서 : .gitignore 파일

후행 공백, 그들은 fnmatch(3), 예를 들어, 대한 을 인용하지 않는 "path\ ", 경고 및 무시됩니다. 엄밀히 말하면 말하기는 이것이 이전 버전과 호환되지 않는 변경이지만 매우 익숙하지 않은 은 정상적인 사용자를 물어 뜯어 조정이 쉽고 분명해야합니다.