빈 폴더 구조 커밋 (git 사용)
이 질문에 이미 답변이 있습니다.
프로젝트 루트에 데이터 디렉토리가 있습니다. 이미지 디렉토리와 일부 파일이 있습니다. 예를 들면 다음과 같습니다.
data
├── images
│ ├── image1.jpg
│ ├── image2.jpg
│ └── image3.jpg
├── results.csv
└── r.txt
data / 디렉토리 (즉 results.csv 및 r.txt)의 파일과 images / 디렉토리 (image.jpg, image2.jpg, image3.jpg)의 파일을 무시하려면 gitignore에 무엇을 작성해야합니까?
커밋 할 때 저장소의 폴더 구조는 다음과 같아야합니다.
data/
└── images/
따라서 빈 폴더 구조를 커밋하고 싶습니다.
Git에서는 실제로 폴더가 아니라 파일 만 저장하기 때문에 빈 폴더를 커밋 할 수 없습니다. 실제로 "비어있는"(즉, 커밋 할 수있는 내용이없는 경우) 디렉토리 내에 자리 표시 자 파일을 만들어야합니다.
.gitkeep
커밋하려는 모든 폴더에 파일 을 추가하기 만하면 됩니다.
Windows에서는 폴더에서 마우스 오른쪽 버튼을 클릭하고 여기에서 Git bash를 선택합니다. 그런 다음 다음을 입력하십시오.touch .gitkeep
이것은 쉬워요.
얘기 .gitignore
를 제외한 모든 것을 무시 .gitignore
하고 유지하려는 폴더를. .gitignore
저장소에 보관하려는 폴더에 넣으십시오 .
최상위의 내용 .gitignore
:
# ignore everything except .gitignore and folders that I care about:
*
!images*
!.gitignore
중첩 된 images
폴더에서 이것은 다음과 .gitignore
같습니다.
# ignore everything except .gitignore
*
!.gitignore
.gitignore가있는 폴더에서 무시하지 않으려는 폴더의 이름을 .gitignore에 입력해야합니다. 그렇지 않으면 분명히 무시됩니다.
리포지토리의 폴더는 분명히 비어 있지 않습니다. 각 폴더에는 포함 .gitignore
되지만 해당 부분은 무시할 수 있습니다. :)
.gitkeep 파일을 재귀 적으로 생성
find . -type d -empty -not -path "./.git/*" -exec touch {}/.gitkeep \;
전통적으로 디렉토리 구조를 커밋하고 비우고 싶을 때마다 구조를 만든 다음 리프 디렉토리에 empty.txt
.
그런 다음 커밋 할 준비가 된 항목을 넣으면 empty.txt
파일을 제거 하고 실제 파일을 커밋 할 수 있습니다.
즉
- 데이터/
- 이미지 /
- empty.txt
- 이미지 /
mkdir -p data/images
빌드하는 동안 디렉토리가 있어야하는 경우 Makefile에서 수행하는 것도 고려하십시오 .
충분하지 않은 경우 데이터 / 이미지에 빈 파일을 만들고 데이터를 무시하십시오.
touch data/images/.gitignore
git add data/images/.gitignore
git commit -m "Add empty .gitignore to keep data/images around"
echo data >> .gitignore
git add .gitignore
git commit -m "Add data to .gitignore"
을 사용하여 빈 커밋을 만들 수 git commit --allow-empty
있지만 git은 폴더 자체를 객체로 인식하거나 관심을 갖지 않기 때문에 빈 폴더 구조를 커밋 할 수 없습니다.
FAQ에 따르면 GIT는 빈 디렉토리를 추적하지 않습니다.
However, there are workarounds based on your needs and your project requirements.
Basically if you want to track an empty directory you can place a .gitkeep
file in there. The file can be blank and it will just work. This is Gits way of tracking an empty directory.
Another option is to provide documentation for the directory. You can just add a readme file in it describing its expected usage. Git will track the folder because it has a file in it and you have now provided documentation to you and/or whoever else might be using the source code.
If you are building a web app you may find it useful to just add an index.html file which may contain a permission denied message if the folder is only accessible through the app. Codeigniter does this with all their directories.
Simply add file named as .keep in images folder.you can now stage and commit and also able to add folder to version control.
Create a empty file in images folder $ touch .keep
$ git status
On branch master Your branch is up-to-date with 'origin/master'. Untracked files: (use "git add ..." to include in what will be committed) images/ nothing added to commit but untracked files present (use "git add" to track)
$ git add .
$ git commit -m "adding empty folder"
참고URL : https://stackoverflow.com/questions/14541253/commit-empty-folder-structure-with-git
'IT Share you' 카테고리의 다른 글
Qt를 사용하여 일시 중지 / 대기 기능을 어떻게 생성합니까? (0) | 2020.11.15 |
---|---|
임의의 값으로 배열 만들기 (0) | 2020.11.15 |
NotImplementedException이 존재하는 이유는 무엇입니까? (0) | 2020.11.15 |
IE8 : nth-child 및 : before (0) | 2020.11.15 |
UITextView-XCode 5의 iOS 6에서 글꼴 설정이 작동하지 않음 (0) | 2020.11.15 |