两个git仓库在一个目录中? [英] Two git repositories in one directory?

查看:231
本文介绍了两个git仓库在一个目录中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在一个目录中拥有2个git存储库?我想不会,但是我想我会问。基本上,我想检查我的主目录配置文件(例如.emacs),这些文件应该在我所使用的所有机器上都是通用的,但是为本地文件(例如.emacs.local)提供第二个存储库,其中包含机器特定的配置。我能想到的唯一方法就是在本子目录中配置本地配置,并忽略主git存储库中的子目录。任何其他的想法?如果我明白你在做什么,你可以在一个仓库中处理它,使用单独的分支每台机器以及一个包含常用主目录配置文件的分支。

初始化repo并将通用文件提交给它,也许将MASTER分支重命名为Common。然后为每个与您一起工作的机器创建一个单独的分支,并将机器特定的文件提交到该分支。任何时候你改变你的公共文件,将公共分支合并到每个机器分支并推送到你的其他机器(如果有很多机器,写一个脚本)。

然后在每台机器上签出该机器的分支,其中也包含通用配置文件。

Is it possible to have 2 git repositories in one directory? I'd think not, but thought I'd ask. Basically, I'd like to check in my home directory config files (e.g. .emacs) which should be common across all of the machines I work on, but have a second repository for local files (e.g. .emacs.local), which contains machine-specific configurations. The only way I can think of to do that is to have the local config in a subdirectory and ignore that subdirectory from the main git repository. Any other ideas?

解决方案

If I understand what you're doing, you can handle it all in one repository, using separate branches for each machine, and a branch containing your common home directory config files.

Initialize the repo and commit the common files to it, perhaps renaming the MASTER branch as Common. Then create a separate branch from there for each machine that you work with, and commit machine-specific files into that branch. Any time that you change your common files, merge the common branch into each of the machine branches and push to your other machines (write a script for that if there are many).

Then on each machine, checkout that machine's branch, which will also include the common config files.

这篇关于两个git仓库在一个目录中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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