gpt4 book ai didi

gitignore - 忽略文件夹中生成的文件,但不忽略文件夹

转载 作者:行者123 更新时间:2023-12-02 17:13:33 25 4
gpt4 key购买 nike

我有一个 gulp 任务,可以将 Assets 通过管道传输到一个目录中。我想在我的项目中包含该目录,但通过 .gitignore 文件排除输出的文件。我的 gulp 任务如下所示:

gulp.task('styles', function() {
return sass('app/scss/styles.scss')
.pipe(cleanCSS())
.pipe(gulp.dest('public/stylesheets'))
.pipe(livereload());
});

gulp.task('scripts', function() {
gulp.src('app/js/script.js')
.pipe(webpack(require('./webpack.config.js')))
.pipe(uglify())
.pipe(gulp.dest('public/javascripts'))
.pipe(livereload());
});

文件夹结构:

app
---js
---scss
public(NEED TO KEEP THIS)
---javascripts(NEED TO KEEP THIS)
-----scrpits.min.js**(NEED TO IGNORE THIS)**
---stylesheets(NEED TO KEEP THIS)
-----styles.css**(NEED TO IGNORE THIS)**

所以在 .gitignore 如果我去:

/public

这会忽略所有内容,这不是我想要的。

我发现了这个问题:How can I add an empty directory to a Git repository?有人提出了一个“解决方法”,获得了 54 票赞成:

"Andy Lester is right, but if your directory just needs to be empty, and not empty empty, you can put an empty .gitignore file in there as a workaround..."

所以现在我去:

app
---js
---scss
public(NEED TO KEEP THIS)
---javascripts(NEED TO KEEP THIS)
-----scrpits.min.js**(NEED TO IGNORE THIS)**
-----.gitignore
---stylesheets(NEED TO KEEP THIS)
-----styles.css**(NEED TO IGNORE THIS)**
-----.gitignore

并从接受的答案中采纳了一个建议并做了:

/public/!.gitignore

但还是没有得到想要的结果。

如何将输出文件夹提交到 gulp 任务的存储库?

最佳答案

好吧,我想通了:

/public/**/*.js
/public/**/*.css

本质上,/public 下一级的任何文件夹中的任何文件都应被忽略。

关于gitignore - 忽略文件夹中生成的文件,但不忽略文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47797177/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com