.gitignore排除文件夹,但包括特定的子文件夹

发布于 2025-01-24 21:12:40 字数 248 浏览 4 评论 0 原文

我有一个文件夹 application/,我将其添加到 .gitignore
应用程序/ -folder中,有一个文件夹 application/language/gr

如何包含此文件夹?

我已经尝试过:

application/
!application/language/gr/

I have a folder application/, which I add to the .gitignore.
Inside the application/-folder there is a folder application/language/gr.

How can I include this folder?

I've tried this:

application/
!application/language/gr/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(20

画▽骨i 2025-01-31 21:12:40

如果排除应用程序/,则将始终排除其下的所有内容(即使以后的负面排除模式(“ Unignore”)可能与 application/下的某些内容相匹配。

要做自己想做的事,您必须“ Unignore”要“ Unignore”的任何内容的每个父目录。通常,您最终会成对为这种情况编写规则:忽略目录中的所有内容,但不是某些子目录。

# you can skip this first one if it is not already excluded by prior patterns
!application/

application/*
!application/language/

application/language/*
!application/language/gr/

注意
尾随/*很重要:

  • 模式 dir/不包括名为 dir 和(隐式)所有内容的目录。
    使用 dir/,git永远不会在 dir 下查看任何内容,因此永远不会将任何“非隔离”模式应用于 dir
  • 模式 dir/* dir 本身没有说明;它只是不包括 dir 下的所有内容。
    使用 dir/*,git将处理 dir 的直接内容,使其他模式有机会“取消”内容(!dir) /sub/)。

If you exclude application/, then everything under it will always be excluded (even if some later negative exclusion pattern (“unignore”) might match something under application/).

To do what you want, you have to “unignore” every parent directory of anything that you want to “unignore”. Usually you end up writing rules for this situation in pairs: ignore everything in a directory, but not some certain subdirectory.

# you can skip this first one if it is not already excluded by prior patterns
!application/

application/*
!application/language/

application/language/*
!application/language/gr/

Note
The trailing /* is significant:

  • The pattern dir/ excludes a directory named dir and (implicitly) everything under it.
    With dir/, Git will never look at anything under dir, and thus will never apply any of the “un-exclude” patterns to anything under dir.
  • The pattern dir/* says nothing about dir itself; it just excludes everything under dir.
    With dir/*, Git will process the direct contents of dir, giving other patterns a chance to “un-exclude” some bit of the content (!dir/sub/).
财迷小姐 2025-01-31 21:12:40

Karsten Blees (kblees) for Git 1.9/2.0 (Q1 2014) clarifies that case:

可选的前缀“ ”,否定模式;以前模式排除的任何匹配文件都将再次包含在内。

如果排除该文件的父目录,则不可能重新包含文件。 (*
*:除非在git 2.8+中满足某些条件,请参见下文)
GIT出于性能原因没有列出排除目录,因此包含文件上的任何模式都没有效果,无论它们在何处的定义。

将Backslash(“ \/code>”)放在第一个“ ”的前面,以开始于字面的“ ”。 ,例如,“ \!

示例除了特定目录 foo/bar (注意/* - 没有斜线,通配符还将在 foo/ bar ):


 --------------------------------------------------------------
     $ cat .gitignore
     # exclude everything except directory foo/bar
     /*
     !/foo
     /foo/*
     !/foo/bar
 --------------------------------------------------------------

在您的情况下:

application/*
!application/**/
application/language/*
!application/language/**/
!application/language/gr/**

您必须首先白列表文件夹,才能在给定文件夹中使用白列表文件。


更新2016年2月/2016年3月:

请注意,使用GIT 2.9.x/2.10(2016年中?),如果该文件的父目录被排除在外,则可以重新包含文件。

nguyễntháingọcduy( pclouds

因此,对于Git 2.9+,这实际上可能有效,但最终被恢复了:

application/
!application/language/gr/

Commit 59856de from Karsten Blees (kblees) for Git 1.9/2.0 (Q1 2014) clarifies that case:

gitignore.txt: clarify recursive nature of excluded directories

An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again.

It is not possible to re-include a file if a parent directory of that file is excluded. (*)
(*: unless certain conditions are met in git 2.8+, see below)
Git doesn't list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined.

Put a backslash ("\") in front of the first "!" for patterns that begin with a literal "!", for example, "\!important!.txt".

Example to exclude everything except a specific directory foo/bar (note the /* - without the slash, the wildcard would also exclude everything within foo/bar):

 --------------------------------------------------------------
     $ cat .gitignore
     # exclude everything except directory foo/bar
     /*
     !/foo
     /foo/*
     !/foo/bar
 --------------------------------------------------------------

In your case:

application/*
!application/**/
application/language/*
!application/language/**/
!application/language/gr/**

You must white-list folders first, before being able to white-list files within a given folder.


Update Feb/March 2016:

Note that with git 2.9.x/2.10 (mid 2016?), it might be possible to re-include a file if a parent directory of that file is excluded if there is no wildcard in the path re-included.

Nguyễn Thái Ngọc Duy (pclouds) is trying to add this feature:

So with git 2.9+, this could have actually worked, but was ultimately reverted:

application/
!application/language/gr/
樱娆 2025-01-31 21:12:40

@chris Johnsen的答案很棒,但是有了较新的Git版本(1.8.2或更高版本),有一个双重星号模式,您可以利用一些更多的速记解决方案:

# assuming the root folder you want to ignore is 'application'
application/**/*

# the subfolder(s) you want to track:
!application/language/gr/

这样您就不必“ Unignore”父母。您要跟踪的子文件夹的目录。


使用GIT 2.17.0(不确定此版本之前的时间。例如:

# assuming the root folder you want to ignore is 'application'
application/**

# Explicitly track certain content nested in the 'application' folder:
!application/language/
!application/language/gr/
!application/language/gr/** # Example adding all files & folder in the 'gr' folder
!application/language/gr/SomeFile.txt # Example adding specific file in the 'gr' folder

@Chris Johnsen's answer is great, but with a newer versions of Git (1.8.2 or later), there is a double asterisk pattern you can leverage for a bit more shorthand solution:

# assuming the root folder you want to ignore is 'application'
application/**/*

# the subfolder(s) you want to track:
!application/language/gr/

This way you don't have to "unignore" parent directory of the subfolder you want to track.


With Git 2.17.0 (Not sure how early before this version. Possibly back to 1.8.2), using the ** pattern combined with excludes for each subdirectory leading up to your file(s) works. For example:

# assuming the root folder you want to ignore is 'application'
application/**

# Explicitly track certain content nested in the 'application' folder:
!application/language/
!application/language/gr/
!application/language/gr/** # Example adding all files & folder in the 'gr' folder
!application/language/gr/SomeFile.txt # Example adding specific file in the 'gr' folder
思念满溢 2025-01-31 21:12:40

我发现此实际上有效。

**/node_modules/*
!**/node_modules/keep-dir

I've found only this actually works.

**/node_modules/*
!**/node_modules/keep-dir
美人骨 2025-01-31 21:12:40

关于此问题有很多类似的问题,所以我会发布我之前写的内容:

让我在机器上工作的唯一方法就是这样做:

# Ignore all directories, and all sub-directories, and it's contents:
*/*

#Now ignore all files in the current directory 
#(This fails to ignore files without a ".", for example 
#'file.txt' works, but 
#'file' doesn't):
*.*

#Only Include these specific directories and subdirectories:
!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个子目录,那么我仍然需要阐明这一点。

这是从 @yarin的评论中的: https://stackoverflow.com/a/5250314/16966153

这些是有用的主题:

*
*/*
**/**

**/wp-content/themes/**

/wp-content/themes/**/*

都不适合我。有很多反复试验!

There are a bunch of similar questions about this, so I'll post what I wrote before:

The only way I got this to work on my machine was to do it this way:

# Ignore all directories, and all sub-directories, and it's contents:
*/*

#Now ignore all files in the current directory 
#(This fails to ignore files without a ".", for example 
#'file.txt' works, but 
#'file' doesn't):
*.*

#Only Include these specific directories and subdirectories:
!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/*/*/*/*/*

Notice how you have to explicitly allow content for each level you want to include. So if I have subdirectories 5 deep under themes, I still need to spell that out.

This is from @Yarin's comment here: https://stackoverflow.com/a/5250314/1696153

These were useful topics:

I also tried

*
*/*
**/**

and **/wp-content/themes/**

or /wp-content/themes/**/*

None of that worked for me, either. Lots of trial and error!

橘虞初梦 2025-01-31 21:12:40

最简单,最佳方法是尝试手动添加文件(通常,这优先于 .gitignore style规则):

git add /path/to/module

如果文件已经已经存在,则可能需要 -f 被忽略。您甚至可能需要 -n 意图添加 flag,以建议您 Will 添加它们,但不要立即。我经常为新文件做这件事,我还没有准备好上演。


这是一个a 答案的副本张贴在很容易成为重复的QA上。我在这里将其重新发布以提高可见性 - 我发现不拥有一系列Gitignore规则会更容易。

The simplest and probably best way is to try adding the files manually (generally this takes precedence over .gitignore-style rules):

git add /path/to/module

You might need -f if the file is already ignored. You may even want the -N intent to add flag, to suggest you will add them, but not immediately. I often do this for new files I’m not ready to stage yet.


This a copy of an answer posted on what could easily be a duplicate QA. I am reposting it here for increased visibility—I find it easier not to have a mess of gitignore rules.

嘦怹 2025-01-31 21:12:40

我的Jetbrains Intellij Idea .gitignore -configuration,我需要排除整个 .idea 文件夹

.idea
!.idea/
.idea/*
!.idea/runConfigurations/

。 >
“ noreferrer”> httpps:// https://github.com/github.com/daggerok/daggerignore-gitignore-igitignore-idea-idea-runea-runco​​nconfigurations #排除-IDEA-EXCEPT-IDEARUNCONFIGURATIONS

My JetBrains IntelliJ IDEA .gitignore-configuration, where I need to exclude whole .idea folder except .idea/runConfigurations:

.idea
!.idea/
.idea/*
!.idea/runConfigurations/

Further details:
https://github.com/daggerok/gitignore-idea-runConfigurations#exclude-idea-except-idearunconfigurations

破晓 2025-01-31 21:12:40

我想跟踪/etc/nagios/中的Nagios配置文件以及/usr/lib64/lib64/nagios/plugins/plugins/中的插件。为此,我在/中初始化了git repo,并使用了以下排除列表:

/*
!etc
etc/*
!etc/nagios
!usr
usr/*
!usr/lib64
usr/lib64/*
!usr/lib64/nagios
usr/lib64/nagios/*
!usr/lib64/nagios/plugins

git沿着这样的列表走下去:

/*             exclude everything under / ...
!etc           but include /etc back
etc/*             exclude everything under /etc/...
!etc/nagios       but include /etc/nagios back
!usr           but include /usr back
usr/*             exclude everything under /usr/...
                  and so on...

I wanted to track Nagios configuration files located in /etc/nagios/ together with the plugins in /usr/lib64/nagios/plugins/. For this I have initialized a git repo in / and used the following exclusion list:

/*
!etc
etc/*
!etc/nagios
!usr
usr/*
!usr/lib64
usr/lib64/*
!usr/lib64/nagios
usr/lib64/nagios/*
!usr/lib64/nagios/plugins

Git walks down the list like that:

/*             exclude everything under / ...
!etc           but include /etc back
etc/*             exclude everything under /etc/...
!etc/nagios       but include /etc/nagios back
!usr           but include /usr back
usr/*             exclude everything under /usr/...
                  and so on...
痕至 2025-01-31 21:12:40

填写此工作!

!/Bin/

将一个名为 .gitignore 的文件添加到子文件夹中,然后为我

add a file named .gitignore to subfolder, then fill with

!/Bin/

this works for me!

岁吢 2025-01-31 21:12:40

我在这里发现了类似的情况,默认情况下,在Laravel中, .gitignore 使用Asterix忽略所有内容,然后覆盖公共目录。
(这也是与主要答案@chris Johnsen的解决方案相同的解决方案,也许有点薄,更简洁。)

*
!public
!.gitignore

如果您遇到OP方案,这是不够的。

如果要提交 public 的特定子文件夹,请在 public> public/production 目录中说明您要包含的文件,这些文件是一个subfolter deep,例如,例如 public/product/a/b.jpg 即使您特别添加了!/public/production !public/products/*<,它们也无法正确检测到它们。 /code>等。

解决方案是要确保您为这样的每个路径级别添加一个条目以覆盖所有路径。

*
!.gitignore
!public/
!public/*/
!public/products/
!public/products/*
!public/products/*/
!public/products/*/
!public/products/*/*

I have found a similar case here, where in laravel by default, .gitignore ignores all using asterix, then overrides the public directory.
( This is also the same solution as the main answer @Chris Johnsen, just a bit thinner and more concise maybe.)

*
!public
!.gitignore

This is not sufficient if you run into the OP scenario.

If you want to commit a specific subfolders of public, say for e.g. in your public/products directory you want to include files that are one subfolder deep e.g. to include public/products/a/b.jpg they wont be detected correctly, even if you add them specifically like this !/public/products, !public/products/*, etc..

The solution is to make sure you add an entry for every path level like this to override them all.

*
!.gitignore
!public/
!public/*/
!public/products/
!public/products/*
!public/products/*/
!public/products/*/
!public/products/*/*
邮友 2025-01-31 21:12:40

Gitignore-指定有意忽略的未跟踪文件。

除了特定目录 foo/bar (请注意/* - 没有斜线,通配符还将排除 foo/bar ):

$ cat .gitignore
# exclude everything except directory foo/bar
/*
!/foo
/foo/*
!/foo/bar

WordPress 的另一个示例:

!/wp-content
wp-content/*
!/wp-content/plugins
wp-content/plugins/*
!wp-content/plugins/my-awesome-plugin

此处的更多信息: https:// git-scm.com/docs/gitignore

gitignore - Specifies intentionally untracked files to ignore.

Example to exclude everything except a specific directory foo/bar (note the /* - without the slash, the wildcard would also exclude everything within foo/bar):

$ cat .gitignore
# exclude everything except directory foo/bar
/*
!/foo
/foo/*
!/foo/bar

Another example for WordPress:

!/wp-content
wp-content/*
!/wp-content/plugins
wp-content/plugins/*
!wp-content/plugins/my-awesome-plugin

More informations in here: https://git-scm.com/docs/gitignore

烟花易冷人易散 2025-01-31 21:12:40

因此,由于许多程序员使用节点。符合此问题的用例是排除 node_modules 除一个模块模块-A 例如:例如:

!node_modules/

node_modules/*
!node_modules/module-a/

So , since many programmers uses node . the use case which meets this question is to exclude node_modules except one module module-a for example:

!node_modules/

node_modules/*
!node_modules/module-a/
未蓝澄海的烟 2025-01-31 21:12:40

添加其他答案:

!/.vs/              <== include this folder to source control, folder only, nothing else
/.vs/*              <== but ignore all files and sub-folder inside this folder
!/.vs/ProjectSettings.json <== but include this file to source control
!/.vs/config/       <== then include this folder to source control, folder only, nothing else
!/.vs/config/*      <== then include all files inside the folder

这里是结果:

”在此处输入图像说明”

Add an additional answer:

!/.vs/              <== include this folder to source control, folder only, nothing else
/.vs/*              <== but ignore all files and sub-folder inside this folder
!/.vs/ProjectSettings.json <== but include this file to source control
!/.vs/config/       <== then include this folder to source control, folder only, nothing else
!/.vs/config/*      <== then include all files inside the folder

here is result:

enter image description here

似最初 2025-01-31 21:12:40

这对我有用:

**/.idea/**
!**/.idea/copyright/
!.idea/copyright/profiles_settings.xml
!.idea/copyright/Copyright.xml

This worked for me:

**/.idea/**
!**/.idea/copyright/
!.idea/copyright/profiles_settings.xml
!.idea/copyright/Copyright.xml
丢了幸福的猪 2025-01-31 21:12:40

类似于

git add -f。

Similar to this comment, none of the solutions and patterns worked for me; forcing git to add the files and folders that should be excluded, worked:

git add -f .

对你的占有欲 2025-01-31 21:12:40

特别是对于较旧的Git版本,大多数建议无法正常工作。
如果是这样,我将在目录中放置一个单独的.gitignore,无论其他设置如何,我希望将内容包含在其中,并允许所需的内容。

例如:
/.gitignore

# ignore all .dll files
*.dll

/dependendency_files/.gitignore

# include everything
!*

,因此包括 /distionency_files(甚至.dll文件)中的所有内容都可以很好地包含。

Especially for the older Git versions, most of the suggestions won't work that well.
If that's the case, I'd put a separate .gitignore in the directory where I want the content to be included regardless of other settings and allow there what is needed.

For example:
/.gitignore

# ignore all .dll files
*.dll

/dependency_files/.gitignore

# include everything
!*

So everything in /dependency_files (even .dll files) are included just fine.

ぶ宁プ宁ぶ 2025-01-31 21:12:40

在WordPress中,这对我有所帮助:

wp-admin/
wp-includes/
/wp-content/*
!wp-content/plugins/
/wp-content/plugins/*
!/wp-content/plugins/plugin-name/
!/wp-content/plugins/plugin-name/*.*
!/wp-content/plugins/plugin-name/**

In WordPress, this helped me:

wp-admin/
wp-includes/
/wp-content/*
!wp-content/plugins/
/wp-content/plugins/*
!/wp-content/plugins/plugin-name/
!/wp-content/plugins/plugin-name/*.*
!/wp-content/plugins/plugin-name/**
最笨的告白 2025-01-31 21:12:40

只是沿着目录结构走的另一个例子,以便准确地获得您想要的东西。注意:我没有排除 library/,但 library/**/*

# .gitignore file
Library/**/*
!Library/Application Support/
!Library/Application Support/Sublime Text 3/
!Library/Application Support/Sublime Text 3/Packages/
!Library/Application Support/Sublime Text 3/Packages/User/
!Library/Application Support/Sublime Text 3/Packages/User/*macro
!Library/Application Support/Sublime Text 3/Packages/User/*snippet
!Library/Application Support/Sublime Text 3/Packages/User/*settings
!Library/Application Support/Sublime Text 3/Packages/User/*keymap
!Library/Application Support/Sublime Text 3/Packages/User/*theme
!Library/Application Support/Sublime Text 3/Packages/User/**/
!Library/Application Support/Sublime Text 3/Packages/User/**/*macro
!Library/Application Support/Sublime Text 3/Packages/User/**/*snippet
!Library/Application Support/Sublime Text 3/Packages/User/**/*settings
!Library/Application Support/Sublime Text 3/Packages/User/**/*keymap
!Library/Application Support/Sublime Text 3/Packages/User/**/*theme

&gt; git添加库

&gt; git状态

On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    new file:   Library/Application Support/Sublime Text 3/Packages/User/Default (OSX).sublime-keymap
    new file:   Library/Application Support/Sublime Text 3/Packages/User/ElixirSublime.sublime-settings
    new file:   Library/Application Support/Sublime Text 3/Packages/User/Package Control.sublime-settings
    new file:   Library/Application Support/Sublime Text 3/Packages/User/Preferences.sublime-settings
    new file:   Library/Application Support/Sublime Text 3/Packages/User/RESTer.sublime-settings
    new file:   Library/Application Support/Sublime Text 3/Packages/User/SublimeLinter/Monokai (SL).tmTheme
    new file:   Library/Application Support/Sublime Text 3/Packages/User/TextPastryHistory.sublime-settings
    new file:   Library/Application Support/Sublime Text 3/Packages/User/ZenTabs.sublime-settings
    new file:   Library/Application Support/Sublime Text 3/Packages/User/adrian-comment.sublime-macro
    new file:   Library/Application Support/Sublime Text 3/Packages/User/json-pretty-generate.sublime-snippet
    new file:   Library/Application Support/Sublime Text 3/Packages/User/raise-exception.sublime-snippet
    new file:   Library/Application Support/Sublime Text 3/Packages/User/trailing_spaces.sublime-settings

Just another example of walking down the directory structure to get exactly what you want. Note: I didn't exclude Library/ but Library/**/*

# .gitignore file
Library/**/*
!Library/Application Support/
!Library/Application Support/Sublime Text 3/
!Library/Application Support/Sublime Text 3/Packages/
!Library/Application Support/Sublime Text 3/Packages/User/
!Library/Application Support/Sublime Text 3/Packages/User/*macro
!Library/Application Support/Sublime Text 3/Packages/User/*snippet
!Library/Application Support/Sublime Text 3/Packages/User/*settings
!Library/Application Support/Sublime Text 3/Packages/User/*keymap
!Library/Application Support/Sublime Text 3/Packages/User/*theme
!Library/Application Support/Sublime Text 3/Packages/User/**/
!Library/Application Support/Sublime Text 3/Packages/User/**/*macro
!Library/Application Support/Sublime Text 3/Packages/User/**/*snippet
!Library/Application Support/Sublime Text 3/Packages/User/**/*settings
!Library/Application Support/Sublime Text 3/Packages/User/**/*keymap
!Library/Application Support/Sublime Text 3/Packages/User/**/*theme

> git add Library

> git status

On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    new file:   Library/Application Support/Sublime Text 3/Packages/User/Default (OSX).sublime-keymap
    new file:   Library/Application Support/Sublime Text 3/Packages/User/ElixirSublime.sublime-settings
    new file:   Library/Application Support/Sublime Text 3/Packages/User/Package Control.sublime-settings
    new file:   Library/Application Support/Sublime Text 3/Packages/User/Preferences.sublime-settings
    new file:   Library/Application Support/Sublime Text 3/Packages/User/RESTer.sublime-settings
    new file:   Library/Application Support/Sublime Text 3/Packages/User/SublimeLinter/Monokai (SL).tmTheme
    new file:   Library/Application Support/Sublime Text 3/Packages/User/TextPastryHistory.sublime-settings
    new file:   Library/Application Support/Sublime Text 3/Packages/User/ZenTabs.sublime-settings
    new file:   Library/Application Support/Sublime Text 3/Packages/User/adrian-comment.sublime-macro
    new file:   Library/Application Support/Sublime Text 3/Packages/User/json-pretty-generate.sublime-snippet
    new file:   Library/Application Support/Sublime Text 3/Packages/User/raise-exception.sublime-snippet
    new file:   Library/Application Support/Sublime Text 3/Packages/User/trailing_spaces.sublime-settings
哆啦不做梦 2025-01-31 21:12:40

我想跟踪jQuery Production JS文件,这有效:

node_modules/*
!node_modules/jquery
node_modules/jquery/*
!node_modules/jquery/dist/*

I wanted to track jquery production js files and this worked:

node_modules/*
!node_modules/jquery
node_modules/jquery/*
!node_modules/jquery/dist/*
网白 2025-01-31 21:12:40

我经常在CLI中使用此解决方法,其中我没有配置我的 .gitignore ,而是创建一个单独的 .include 文件,我在其中定义(sub)我希望直接包含目录,或者直接或递归地忽略了 .gitignore

因此,我

git add `cat .include`

在登台期间还使用之前使用。

对于OP,我建议使用 .include 具有以下行:

<parent_folder_path>/application/language/gr/*

注意:使用 cat 不允许使用别名(在中。Include。 )用于指定$ home(或任何其他特定目录)。这是因为行 homedir/app1/*
当传递到时,使用上述命令将添加为 git添加'homedir/app1/*',并将字符封闭在单个引号('')中引号中的每个字符,从而阻止别名(例如 homedir )功能(请参阅 bash单引号)。

这是我在repo .include 文件的示例。 a>。

/home/abhirup/token.txt
/home/abhirup/.include
/home/abhirup/.vim/*
/home/abhirup/.viminfo
/home/abhirup/.bashrc
/home/abhirup/.vimrc
/home/abhirup/.condarc

I often use this workaround in CLI where instead of configuring my .gitignore, I create a separate .include file where I define the (sub)directories I want included in spite of directories directly or recursively ignored by .gitignore.

Thus, I additionally use

git add `cat .include`

during staging, before committing.

To the OP, I suggest using a .include which has these lines:

<parent_folder_path>/application/language/gr/*

NOTE: Using cat does not allow usage of aliases (within .include) for specifying $HOME (or any other specific directory). This is because the line homedir/app1/*
when passed to git add using the above command appears as git add 'homedir/app1/*', and enclosing characters in single quotes ('') preserves the literal value of each character within the quotes, thus preventing aliases (such as homedir) from functioning (see Bash Single Quotes).

Here is an example of a .include file I use in my repo here.

/home/abhirup/token.txt
/home/abhirup/.include
/home/abhirup/.vim/*
/home/abhirup/.viminfo
/home/abhirup/.bashrc
/home/abhirup/.vimrc
/home/abhirup/.condarc
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文