是否可以将所有新文件添加到自动添加到Git的目录中? [英] Can I have all new files added to a directory automatically added to Git?

查看:1083
本文介绍了是否可以将所有新文件添加到自动添加到Git的目录中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将Git配置为自动添加添加到目录中的所有新文件?

Is there a way to configure Git to automatically add any new files that are added to a directory?

我知道如何从命令行执行此操作;但是有办法自动发生吗?

I know how to do this from the command line; but is there a way to have it happen automatically?

推荐答案

如果您知道新文件的位置(至少足以使用路径语法和通配符描述位置),则可以使用提交 Git挂钩.

If you know where the new files are located (at least enough to use path syntax and wildcards to describe the location) then you can accomplish this with a pre-commit Git hook.

例如,如果您的项目的.db_migrations文件夹,您可以通过放置

For example, if you have Flask-Migrate database migrations in your project's .db_migrations folder you can ensure that they are all added before your commits by placing

git add .db_migrations/versions/*.py

在项目的/.git/hooks/pre-commit文件中.

这篇关于是否可以将所有新文件添加到自动添加到Git的目录中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆