prosource

gitignore에 .gitignore 추가

probook 2023. 7. 17. 21:14
반응형

gitignore에 .gitignore 추가

다음을 추가할 수 있습니까?.gitignore로 철하다..gitignore그 자체?

.gitignore

하지만 작동하지 않습니다.

편집된 파일에 표시하지 않습니다.

.gitignore파일의 목적은 프로젝트에서 공동 작업하는 모든 사용자가 생성된 캐시 파일과 같은 프로젝트의 일반 파일을 실수로 커밋하지 않도록 하는 것입니다.그러므로 당신은 무시해서는 안됩니다..gitignore저장소에 포함되어야 하기 때문입니다.

하나의 저장소에 있는 파일만 무시하고 무시 목록(예: 개인 파일)을 커밋하지 않으려면 다음에 파일을 추가할 수 있습니다..git/info/exclude그 저장소에 있습니다.

컴퓨터의 모든 리포지토리에서 특정 파일을 무시하려면 파일을 생성할 수 있습니다.~/.gitignore_global그리고 나서 뛰어요.

git config --global core.excludesfile ~/.gitignore_global

.gitignore는 체크인된 적이 없는 경우 자신을 무시할 수 있습니다.

mhaase@ubuntu:~$ git --version
git version 1.7.9.5
mhaase@ubuntu:~$ git init temp
Initialized empty Git repository in /home/mhaase/temp/.git/
mhaase@ubuntu:~$ cd temp
mhaase@ubuntu:~/temp$ touch .gitignore foo bar baz bat
mhaase@ubuntu:~/temp$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       .gitignore
#       bar
#       bat
#       baz
#       foo
mhaase@ubuntu:~/temp$ echo "foo" >> .gitignore
mhaase@ubuntu:~/temp$ echo ".gitignore" >> .gitignore
mhaase@ubuntu:~/temp$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       bar
#       bat
#       baz
nothing added to commit but untracked files present (use "git add" to track)

.gitignore(자체를 무시하라고 말하기 전에)를 체크인하면 나중에 자체를 무시하도록 수정하더라도 항상 git 상태로 표시됩니다.

이렇게 할 좋은 이유는 없습니다.복제본에 대해서만 파일을 무시하려면 파일을 추가합니다..git/info/exclude에 없는.gitignore파일.

입력 후.gitignoregitignore 파일에서 다음을 시도합니다.

git rm -r --cached .
git add --all
git commit -m "ignoring gitignore"
git push --set-upstream origin master

이미 말했듯이, 여러 사용자가 repo를 공유하는 경우 gitignore를 무시하면 역효과를 낼 수 있습니다.

예, 여전히 git에 의해 추적되고 git에 의해 추적되는 파일은 .gitignore에 있더라도 항상 수정된 것으로 표시되기 때문에 편집된 파일에서 볼 수 있습니다.간단히 추적을 해제합니다.

하지만 변경 사항을 적용하거나 재설정하지 않는 이유는 무엇입니까?상태에서 제거하는 것이 훨씬 더 좋은 방법입니다.또한 리포의 모든 신규 클론은 해당 복제본을 추가해야 합니다..gitignore귀찮을 수도 있습니다.

언급URL : https://stackoverflow.com/questions/10176875/add-gitignore-to-gitignore

반응형