git:每个遥控器都有不同的 .gitignore 文件 [英] git: have different .gitignore file for each remote

查看:30
本文介绍了git:每个遥控器都有不同的 .gitignore 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个远程仓库,我想在其中提交某些文件(编译后的文件以将它们部署在云计算平台上),但我不想将它们部署在 github 上...

I have a remote repo in which I want to commit certain files (the compiled files to deploy them on a cloud computing platform), but I don't want to deploy them on github...

是否有某种方法可以使用不同的 .gitignore 文件,每个远程文件一个?

is there some way to have to different .gitignore files, one for each remote?

推荐答案

这在 git 模型中没有意义.提交包含文件集;所有 .gitignore 文件所做的就是告诉 UI 不要自动添加匹配特定模式的文件.这实际上意味着具有几乎相同但仅包含文件子集的并行提交集.

This doesn't really make sense in git's model. Commits contain sets of files; all .gitignore files do is tell the UI not to automatically add files matching certain patterns. What this would effectively mean is to have parallel sets of commits that are almost the same, but containing only a subset of the files.

可以使用分支方案来做到这一点,在该方案中,您有一个部署"分支,它从 master 分支中分离出来,并且是相同的,但包含额外的编译文件.这甚至可以使用 git hooks 自动编译文件并将它们添加到 repo.我正在设想这样的结构:

It'd be possible to do this with a branching scheme, where you have a "deployment" branch that splits off of master and is the same but contains the additional compiled files. This could even be automated with git hooks to automatically compile the files and add them to the repo. I'm envisioning a structure like this:

master:       A ---> B ---> C ---> D
                                 
                                  
deployment:      -> A'  -> B'  -> C'  -> D'

即每次某个服务器在 master 上获得新提交时,它都会构建项目,将构建的文件添加到来自 D 的新提交,并将其提交到部署分支——然后不必将其推送到 github.

i.e. every time a certain server gets a new commit on master, it builds the project, adds the built files to a new commit from D, and commits that to the deployment branch -- which then doesn't have to be pushed to github.

这篇关于git:每个遥控器都有不同的 .gitignore 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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