全局.gitignore_创建一个全局.gitignore

全局.gitignore

The .gitignore file is cherished by developers because it can keep repositories clean after build files and OS-generated files (like .DS_Store) clutter the structure of your repository. What I find is that I'm constantly adding the same files and directories (like node_modules) to every repository and I find it tedious. I was hoping there was a way to globally ignore those files and directories ... and I've found it.

.gitignore文件是开发人员所.gitignore文件,因为它可以在构建文件和OS生成的文件(例如.DS_Store )使您的存储库结构混乱之后使存储库保持干净。 我发现,我不断地向每个存储库添加相同的文件和目录(例如node_modules ),并且发现它很乏味。 我希望有一种全局忽略这些文件和目录的方法……我已经找到了。

You can create your global .gitignore with this magic:

您可以使用以下魔术创建全局.gitignore


# Declare the global .gitignore
git config --global core.excludesfile ~/.gitignore_global

# Create the .gitignore_global file
touch .gitignore_global

# Go into edit mode so you can add the unwanted file listing
vim .gitignore_global


The snippet above creates a .gitignore_global in your user directory which is respected throughout your user directory. Now you don't have to explicitly, repeatedly add the same files and directories to individual .gitignore files! Excellent!

上面的代码段在您的用户目录中创建了一个.gitignore_global在整个用户目录中都受到尊重。 现在,您不必显式地将相同的文件和目录重复添加到单个.gitignore文件中! 优秀的!

This shouldn't be considered a great solution for collaborative repositories though -- someone else will inadvertently submit unwanted files and directories because the repo's own .gitignore doesn't contain the unwanted file listing. For your own purposes, however, a global .gitignore is aces!

但是,这不应被认为是协作存储库的理想解决方案-他人会无意中提交不需要的文件和目录,因为存储库自己的.gitignore不包含不需要的文件列表。 但是,出于您自己的目的,全局.gitignore是ace!

翻译自: https://davidwalsh.name/global-gitignore

全局.gitignore

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值