최근에 git을 사용하기 시작했습니다… 방금 '~'가 결국 내 파일의 클론을 발견했습니다… 왜 이런 일이 일어나고 있습니까?

StackOverflow https://stackoverflow.com/questions/801840

  •  03-07-2019
  •  | 
  •  

문제

나는 GIT를 사용하여 저장소의 변경 사항을 저지르고

이 단계를 따랐습니다

git add .
git commit -m "message"

그러나 저장소에 변경된 파일의 클론이 새 파일에 포함 된 파일의 클론을 발견했습니다.~'마지막에 기호가 추가되었습니다.

왜 이런 일이 일어 났습니까? 그리고 앞으로 어떻게 방지 할 수 있습니까?
또한 "~"로 파일을 제거하는 방법에 대한 몇 가지 생각은 좋을 것입니다.

감사

도움이 되었습니까?

해결책

편집기는 Filename 양식의 백업 파일을 생성합니다. (EMACS는이 작업을 수행합니다. 그렇지 않으면 설득 될 수 있습니다.) Git에게 ~ ~에서 끝나는 파일을 무시하도록 요청하지 않았습니다. 와 함께 git add . 당신은 당신이 무시하지 말라고 요청하지 않은 모든 것을 추가하라고 Git에게 말하고 있습니다.

또한보십시오:Gitignore

다른 팁

To complete bendin's answer, add in your working directory a .gitignore file with for instance:

*~
*.bak
*.old

That .gitignore file will have to be added and committed in order to persist through 'git clone', since there are several levels of 'gitignore'.

Also some thoughts on how to remove the file with "~" would be great

With gitignore you ignore files that are not yet being tracked, but if you added a file, and later matched it in your .gitignore, it will still be marked as updated when it content changes.

So, the way to remove it from future commits, is using:

git rm *~

In the other hand, if you want to remove the temp files from old commits, you should look at git filter-branch. Be careful if you've published your repo, as this commands rewrites the history, so backup your repo and be aware of what you're doing if you choose this way.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top