.gitignore를 사용하여 특정 디렉터리를 제외한 모든 항목 무시
제인데, 그 에서 저는 제 에내문내제는사것이있많다트이는가이고웹그싶중다선에택서내적으콘, ▁my▁of▁in▁▁word▁contentively▁my▁commit▁i의 내용만 선택적으로 .themesWordPress에 있는 나머지 중복 파일은 무시하고 폴더를 만듭니다.
.gitignore 파일을 사용하여 파일 형식을 무시한 적이 있습니다. 하지만 특정 폴더 경로를 제외한 모든 것을 무시하는 것과 반대로 사용할 수 있습니까?
root(gitrepo)
/ 워레스프드
/ ( 1) / / (WordPress 사이트 1 ) / wp-content/주제-
/ 2) / / (WordPress 사이트 2 ) / wp-content/주제-
/ 3) / / (WordPress 사이 3 ) / wp-content/주제-
감사합니다
업데이트:
답변을 토대로 다음과 같이 했는데 효과가 없습니다.아이디어 있어요?
# Ignore everything:
*
# Except for wordpress themes:
!*/wp-content/themes/*
다음과 같은 변형도 시도해 보았습니다.
!*/wp-content/themes*
!*wp-content/themes/*
!wp-content/themes/*
!/wordpress/*/wp-content/themes*
!wordpress/*/wp-content/themes*
이것들 중 아무 것도 읽지 않습니다.themes폴더.
제가 한 방법은 다음과 같습니다. 기본적으로 경로를 따라 올라가야 합니다. 어떤 방향으로든 하나 이상의 와일드카드를 사용할 수 없습니다.
# Ignore everything:
*
# Except for the themes directories:
!wordpress/
!wordpress/*/
!wordpress/*/wp-content/
!wordpress/*/wp-content/themes/
!wordpress/*/wp-content/themes/*
!wordpress/*/wp-content/themes/*/*
!wordpress/*/wp-content/themes/*/*/*
!wordpress/*/wp-content/themes/*/*/*/*
!wordpress/*/wp-content/themes/*/*/*/*/*
포함할 각 수준에 대해 콘텐츠를 명시적으로 허용해야 하는 방법에 주목합니다.그래서 제가 주제 아래에 하위 디렉터리 5개가 있다고 해도, 저는 여전히 그것을 철자할 필요가 있습니다.
이것은 나에게만 효과가 있었습니다.만약 누군가가 더 많은 정보에 입각한 설명을 제공하려고 한다면 말입니다.
또한 다음과 같은 답변이 도움이 됩니다.
하는 것을 무시하는 것은 무시하는 사람들이 무시하는 것 같아요.
참고: 이중 와일드카드 '글로브'를 사용하려고 했지만, 이에 따르면 해당 기능은 시스템에 따라 다르며 Mac에서 작동하지 않았습니다.
작동하지 않음:
!**/wp-content/themes/
!**/wp-content/themes/**
위의 것들을 시도해 봤는데 잘 작동하지 않았습니다.더 나은 접근 방식은 다음과 같습니다. https://gist.github.com/444295
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
# content. Or see git's documentation for more info on .gitignore files:
# http://kernel.org/pub/software/scm/git/docs/gitignore.html
# Ignore everything in the root except the "wp-content" directory.
/*
!.gitignore
!wp-content/
# Ignore everything in the "wp-content" directory, except the "plugins"
# and "themes" directories.
wp-content/*
!wp-content/plugins/
!wp-content/themes/
# Ignore everything in the "plugins" directory, except the plugins you
# specify (see the commented-out examples for hints on how to do this.)
wp-content/plugins/*
# !wp-content/plugins/my-single-file-plugin.php
# !wp-content/plugins/my-directory-plugin/
# Ignore everything in the "themes" directory, except the themes you
# specify (see the commented-out example for a hint on how to do this.)
wp-content/themes/*
# !wp-content/themes/my-theme/
첫 번째 줄을 수정합니다.
*
로 변경합니다.
/*
다음과 같은 답변을 시도해 보십시오.
.gitignore로 몇 개의 파일을 제외한 모든 파일을 무시합니다.
# Ignore everything * # But not these files... !.gitignore !script.pl !template.latex # etc... # ...even if they are in subdirectories !*/
하위 디렉터리를 제외한 모든 것을 무시하도록 Git에게 어떻게 말합니까?
이렇게 하면 루트 파일 및 루트 디렉터리가 무시되고 루트 bin 디렉터리가 무시되지 않습니다.
/* /*/ !/bin/이렇게 하면 하위 디렉터리와 해당 파일을 포함한 모든 bin 디렉터리를 얻을 수 있습니다.
패턴 에 느낌표를 (패붙이면앞에느턴로표낌▁(면▁if붙이느▁a▁you▁with▁(▁pattern▁an)!제외된 모든 이전 패턴을 무효화합니다.그래서 아마 모든 것을 무시하고 이 패턴을 사용하여 원하는 것만 허용할 수 있을 것입니다.
다음과 같은 디렉토리 구조를 가지고 있다고 가정합니다.
– sites
– -all
– – – -files
– – – – – -private
– – – – – – – -newspilot
– -default
– – – -files
– – – – – -private
– – – – – – – -newspilot
사이트/모든/파일/개인/뉴스파일 및 사이트/기본값/파일/개인/뉴스파일만 허용하려는 경우 처음에 다음을 시도할 수 있습니다.
sites/*/files/*
!sites/*/files/private/newspilot
이건 틀렸어요!gitignore와 관련하여 까다로운 점은 하위 디렉터리("newspilot")를 커밋에 포함하도록 허용하기 전에 먼저 상위 디렉터리("개인")를 포함하도록 허용해야 한다는 것입니다.
sites/*/files/*
!sites/*/files/private
sites/*/files/private/*
!sites/*/files/private/newspilot
http://www.christianengvall.se/gitignore-exclude-folder-but-include-a-subfolder/
하위 디렉터리가 있는 폴더 하나를 제외하고는 모두 무시해야 했습니다.
저한테는 이게 효과가 있어요
# Ignore everything
/*
# Not these directories
!folder/
# Not these files
!.gitignore
!.env
!file.txt
야린의 대답은 나에게 효과가 있었다, 여기 내 버전이 있다 (나는 그것이 필요하지 않습니다./wordpress하위 디렉터리):
*
!.gitignore
!/wp-content/
!/wp-content/themes/
!/wp-content/themes/*
!/wp-content/themes/*/*
!/wp-content/themes/*/*/*
!/wp-content/themes/*/*/*/*
!/wp-content/themes/*/*/*/*/*
# I don't want to track this one, so it's included here, after the negated patterns.
wp-content/themes/index.php
저는 이 질문에 몇 번이고 돌아와도 항상 어딘가에 갇힙니다.저는 그것을 하는 세부적인 과정을 단계별로 생각해냈습니다.
처에는그사용냥음을 사용합니다.git add실제 내용을 추가합니다.
다른 모든 파일이 추적되지 않은 상태에서 인덱스에 추가된 관련 파일이 표시됩니다.이것은 건설에 도움이 됩니다..gitignore차근차근
$ git add wp-content/themes/my-theme/*
$ git status
Changes to be committed:
new file: wp-content/themes/my-theme/index.php
new file: wp-content/themes/my-theme/style.css
Untracked files:
wp-admin/
wp-content/plugins/
wp-content/themes/twentyeleven/
wp-content/themes/twentytwelve/
...
wp-includes/
...
임시를 합니다.DUMMY.TXT디렉토리에 있는 파일:
$ git status
Changes to be committed:
new file: wp-content/themes/my-theme/index.php
new file: wp-content/themes/my-theme/style.css
Untracked files:
wp-admin/
wp-content/plugins/
wp-content/themes/twentyeleven/
wp-content/themes/twentytwelve/
...
wp-content/themes/my-theme/DUMMY.TXT <<<
...
wp-includes/
...
지금 우리의 목표는 다음과 같은 규칙을 구성하는 것입니다.DUMMY.TXT우리가 끝났을 때 추적되지 않은 상태로 나타나는 유일한 사람입니다.
규칙 추가 시작:
.gitignore
/*
첫 번째는 모든 것을 무시하는 것입니다.추적되지 않은 파일은 모두 사라지고 인덱스된 파일만 표시됩니다.
$ git status
Changes to be committed:
new file: wp-content/themes/my-theme/index.php
new file: wp-content/themes/my-theme/style.css
에 첫 합니다.wp-content
/*
!/wp-content
이제 추적되지 않은 파일이 다시 표시되지만 다음 파일만 표시됩니다.wp-content의 내용
$ git status
Changes to be committed:
new file: wp-content/themes/my-theme/index.php
new file: wp-content/themes/my-theme/style.css
Untracked files:
wp-content/plugins/
wp-content/themes/twentyeleven/
wp-content/themes/twentytwelve/
..
번째 dir에 것을 무시합니다./wp-content/* un-mon-mon .!/wp-content/themes
/*
!/wp-content
/wp-content/*
!/wp-content/themes
이제 추적되지 않은 파일은 다음과 같이 더 좁혀집니다.wp-content/themes
$ git status
Changes to be committed:
new file: wp-content/themes/my-theme/index.php
new file: wp-content/themes/my-theme/style.css
Untracked files:
wp-content/themes/twentyeleven/
wp-content/themes/twentytwelve/
..
더미 파일이 추적되지 않음으로 표시될 때까지 이 과정을 반복합니다.
/*
!/wp-content
/wp-content/*
!/wp-content/themes
/wp-content/themes/*
!/wp-content/themes/my-theme
$ git status
Changes to be committed:
new file: wp-content/themes/my-theme/index.php
new file: wp-content/themes/my-theme/style.css
Untracked files:
wp-content/themes/my-theme/DUMMY.TXT
여러 번 필요성을 느낀 끝에 마침내 해결책을 찾았습니다[1].
/*/
/*.*
!.git*
!/wordpress
한 줄 한 줄 설명:
- 루트에 있는 모든 디렉터리를 무시합니다.
- 루트에 확장명이 있는 모든 파일을 무시합니다.
- 허락하다
.gitignore자체 ( 잠재적으로 그자그체로잠으적재고리그()).gitattributes). - 모든 하위 디렉터리에 원하는 디렉터리 허용
제한 사항(제가 알고 있는 바):
- . ( " " " 를 추가합니다.
/*전체 계획을 깰 수 있습니다.) - 4행)
wordpress는 "으"를 가질 수 ..이름로예으예▁(로:▁(▁name으)라는 으로.wordpress.1작동하지 않음).만약 그것이 있다면 그것은.그런 다음 2행을 제거하고 루트에 있는 모든 파일을 제외하는 다른 방법을 찾습니다. - 가 설치된
git version 2.17.1.windows.2
또 다른 쉬운 해결책:
테마(예:)가 아닌 모든 Wordpress 파일을 무시하려고 합니다.
.gitignore, 내용:
# All wordpress + content of revert ignored directories
wordpress/*
wordpress/wp-content/*
wordpress/wp-content/themes/*
# Revert ignoring directories
!wordpress/
!wordpress/wp-content/
!wordpress/wp-content/themes/
!wordpress/wp-content/themes/my_theme
이 예에서는 .gitignore가 루트 wordpress 디렉토리에 있는 경우 wordpress를 제거할 수 있습니다.
모든 폴더 및 콘텐츠에서 예외적으로 동일한 작업을 수행하여 Git를 무시한 폴더/파일을 차단할 수 있습니다.
결론:
무시하지 않을 경로의 모든 디렉토리를 무시해야 합니다.
그렇지만
무시할 무시되지 않은 디렉토리의 모든 내용을 무시해야 합니다.
더 깨끗한 해결책을 찾으시는 분들은 다음을 시도해보시기 바랍니다.
이 답변의 댓글에서 언급한 것처럼, 당신은 이 방법을 재귀적으로 사용해야 합니다.
에서는 이예는다위웹사설있다습니정어되가이트치에음에에 웹사이트를 했습니다../의 신이있는이 곳.git 및 폴및더.gitignore 설정은 워드프레스에 있습니다../wordpress아래의 모든 항목을 올바르게 무시하는 방법./wordpress테마 디렉토리 자체와는 별도의 디렉토리(wordpress/wp-content/themes/my-theme까지 각 .:), 각 디 리 허 터 렉 려 는 까 리 지 디 야 허 합 니 해 용 다 터 렉 하 용 고 하 시 재 무 를 귀 적 으 로 ▁), ▁you ▁each ▁until
wordpress/*
wordpress/wp-content/*
wordpress/wp-content/themes/*
!wordpress/wp-content
!wordpress/wp-content/themes
!wordpress/wp-content/themes/my-theme
와일드카드로 무시하고 디렉터리 자체를 허용(또는 '따로' 무시)하는 이유로 Git는 내부의 모든 것을 무시하기 전에 디렉터리 내부를 먼저 살펴볼 수 있습니다.그런 다음 Git에게 우리가 지정한 디렉터리를 제외한 모든 것을 무시하라고 말합니다.다음은 동일한 구문이지만 Git가 어떻게 보고 있는지에 대한 순서입니다.
wordpress/* # Ignore everything inside here
!wordpress/wp-content # Apart from this directory
wordpress/wp-content/* # Ignore everything inside here
!wordpress/wp-content/themes # Apart from this directory
wordpress/wp-content/themes/* # Ignore everything inside here
!wordpress/wp-content/themes/my-theme # Apart from this directory
이것이 재귀적 방법의 필요성을 더 잘 이해하는 데 도움이 되기를 바랍니다.
파티에 늦었지만 알 수 없는 깊이를 위해 사용하는 것은 다음과 같습니다(승인된 솔루션에는 알려진 깊이가 필요함)
/*
!.gitignore
!wp-content/
!*/
이런 식으로 wp-content 아래의 모든 것이 무시되지 않습니다.
여기 제 솔루션이 있습니다. 이 솔루션은 다음과 같습니다.wp-content
# Ignore everything except directories
*
!*/
# except everything in the child theme and its required plugin
!/themes/mytheme-child/**
!/plugins/my-plugin/**
# and this file
!.gitignore
및 테스트:
git version 2.20.1 (Apple Git-117)
$ git check-ignore -v .foo foo foo/ themes/foo themes/foo/bar themes/mytheme-child \
themes/mytheme-child/foo plugins/foo plugins/my-plugin plugins/my-plugin/foo .gitignore
.gitignore:2:* .foo
.gitignore:2:* foo
.gitignore:2:* foo/
.gitignore:2:* themes/foo
.gitignore:2:* themes/foo/bar
.gitignore:2:* themes/mytheme-child
.gitignore:6:!/themes/mytheme-child/** themes/mytheme-child/foo
.gitignore:2:* plugins/foo
.gitignore:2:* plugins/my-plugin
.gitignore:7:!/plugins/my-plugin/** plugins/my-plugin/foo
.gitignore:10:!.gitignore .gitignore
그래서 그것은 내가 원하지 않는 모든 것과 내가 지키고 싶은 어떤 것도 올바르게 무시합니다.
코드 해제
https://docs.gitlab.com/ee/workflow/repository_mirroring.html 에 따르면 Gitlab은 보호된 분기를 위한 저장소 미러로 구성됩니다.
코드가 보호된 분기에 푸시되면 해당 코드가 의 준비 및 프로덕션 서버에 미러링됩니다./opt/checkout/repo.git/노골적인 레포다음과 같은 것들post-receive 낚다채아)/opt/checkout/repo.git/hooks/post-receive그런 다음 코드를 작업 디렉토리에 체크아웃합니다.
#!/bin/bash
BRANCH=staging
GIT_DIR=/opt/checkout/repo.git
GIT_WORK_TREE=/opt/bitnami/apps/wordpress/htdocs/wp-content
# on push, checkout the code to the working tree
git checkout -f "${BRANCH}"
# ensure permissions are correct
sudo chown -R bitnami:daemon "${GIT_WORK_TREE}"
sudo chmod -R go-w "${GIT_WORK_TREE}"
자세한 내용은 https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps 를 참조하십시오.
사용해 볼 수 있습니다.
!**/themes/*
위치:
- 무시 거부(계속)
- 폴더 경로를 지정할 필요가 없는 디렉토리 트리(재귀)
- 테마: 포함할 폴더(무엇이든 될 수 있음)
- 해당 폴더의 모든 파일을 **와 함께 모든 하위 폴더를 포함할 수 있으며, 파일(*)을 포함하는 대신 특정 *.dll, *.xy로 지정할 수 있습니다.
제가 한 방법은 다음과 같습니다.
# Ignore everything at root:
/*
# Except for directories:
!wordpress/(WordPress Site 1)/wp-content/themes/
!wordpress/(WordPress Site 1)/wp-content/themes/
!wordpress/(WordPress Site 1)/wp-content/themes/
# Except files:
!README
#Except files of type:
!*.txt
이것이 저에게 효과가 있었습니다.특정 파일 또는 폴더를 제외한 모든 항목을 무시할 수 있습니다.
macOS 시에라
저는 하나의 레포 아래 많은 워드프레스 사이트를 관리하려고 같은 처지에 있습니다.내 디렉토리 구조는 다음과 같습니다.
root (git repo)
(WordPress Site 1)/app/public/wp-content/themes
(WordPress Site 2)/app/public/wp-content/themes
(WordPress Site 3)/app/public/wp-content/themes
는 나는단안있물추싶다습니적고하을 안에 있는 .app/public각 사이트에 대한 폴더.저는 이 페이지의 샘플과 여기에 있는 몇 가지 제안을 시도했고 결국 다음과 같이 시도했습니다.
/(WordPress Site 1)/*
!(WordPress Site 1)/app
(WordPress Site 1)/app/*
!(WordPress Site 1)/app/public
그것은 효과가 있었지만 내가 피하려고 했던 각 사이트에 대해 같은 경로를 무시해야 했습니다.
그런 다음 사이트 이름을 다음으로 변경했습니다.*그리고 그것이 저에게 효과가 있었습니다.그래서 제가 사용하게 된 것은 다음과 같습니다.
/*/*
!*/app
*/app/*
!*/app/public
은 사이트 폴더의 했습니다.app/public루트에 생성하는 모든 사이트의 폴더입니다.
루트의 파일은 무시하지 않고 디렉토리만 무시합니다 :)
이게 도움이 되길 바랍니다.
언급URL : https://stackoverflow.com/questions/5241644/using-gitignore-to-ignore-everything-but-specific-directories
'programing' 카테고리의 다른 글
| @Springboot의 값이 null을 반환합니다. (0) | 2023.06.30 |
|---|---|
| pip3로 패키지를 설치할 때 "Python에서 ssl 모듈을 사용할 수 없습니다. (0) | 2023.06.30 |
| Yup/Formik에서 기본 오류 텍스트를 변경하는 방법? (0) | 2023.06.30 |
| 이메일에서 내 파일에 계속 나타나는 ^M은 무엇입니까? (0) | 2023.06.30 |
| 임의의 json 개체를 webapi에 게시하는 방법 (0) | 2023.06.30 |