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

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

问题描述

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



是否有一些方法需要不同的.gitignore文件,每个远程文件一个?

>这在git的模型中没有意义。提交包含一组文件;所有.gitignore文件都会告诉用户界面不要自动添加匹配某些模式的文件。这实际上意味着具有几乎相同的并行提交集合,但仅包含文件的一部分。



可以做到这一点使用分支机制,在这里你有一个部署分支,它与主分支相同,并且是相同的,但包含额外的编译文件。这甚至可以通过git钩子来自动编译文件并将它们添加到回购库中。我设想一个这样的结构:

  master:A ---> B ---> C ---> D 
\\\
\\\\\
部署: - > A' - > B' - > C' - > D'

即每次某个服务器在主服务器上获得一个新的提交时,它会构建项目,将构建的文件添加到来自D的新提交中,并将其提交给部署分支 - 然后不必将其推送到github。 / p>

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...

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

解决方案

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.

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'

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天全站免登陆