一个目录中有两个 git 存储库? [英] Two git repositories in one directory?

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

问题描述

是否可以在一个目录中拥有 2 个 git 存储库?我想不会,但我想我会问.基本上,我想检查我的主目录配置文件(例如 .emacs),它应该在我工作的所有机器上通用,但有一个本地文件的第二个存储库(例如 .emacs.local),其中包含特定于机器的配置.我能想到的唯一方法是将本地配置放在一个子目录中,并从主 git 存储库中忽略该子目录.还有其他想法吗?

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.

初始化 repo 并将公共文件提交给它,也许将 MASTER 分支重命名为 Common.然后为您使用的每台机器创建一个单独的分支,并将特定于机器的文件提交到该分支中.任何时候更改公共文件时,将公共分支合并到每个机器分支并推送到其他机器(如果有很多,请为此编写脚本).

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