如何组合两个单独的Git存储库? [英] How to I combine two separate Git repositories?
问题描述
我已经克隆了一个 git repo ,里面有我的emacs配置文件。想要在子目录中添加 pylookup 。什么是正确的方法来做到这一点?
以下是我能想到的选项。
-
如果我将它克隆到
〜/ .emacs.d / pylookup /
中并将该文件夹添加到我的emacs库中,当我这样做时:
cd〜/ .emacs.d / pylookup /
git pull
cd〜 /.emacs.d
git commit -a -m更新到pylookup
git push
ie当我在其他机器上执行这些更改时,是否会有新版本的pylookup?
-
是否有一些聪明的技巧与
git submodule
。如果可以,请提供解释,我并不真正了解文档。我将如何修改emacs和pylookup。
-
我会回答2,但是建立一个脚本来更新所有的sub-repos。如果我这样做了,每次pylookup更改时,我都可以在每台机器上运行一次。
我只是让我的emacs仓库忽略 pylookup / *
,并在pylookup更新时在每台机器上更新它。这会让人讨厌,如果有几个回购和几台机器,但我可以忍受它。
几个可能相关的帖子。
- 结合多个git repositories
- 你创建一个 Git子模块:
$ git submodule add git://github.com/tsgates/pylookup.git pylookup
$ git submodule init pylookup
$ git submodule update pylookup
假设有一些pylookup的变化,你想得到它们:
$ cd pylookup
$ git pull origin master
$ cd ..
$ git add pylookup
$ git commit -m跟踪pylookup的新提交
I have cloned a git repo which has my emacs config files in. I would like to add pylookup in a subdirectory. What is the correct way to do this?
Below are the options I can think of.
If I clone it into
~/.emacs.d/pylookup/
and add that folder to my emacs repo, will that update properly when I do:cd ~/.emacs.d/pylookup/ git pull cd ~/.emacs.d git commit -a -m "updates to pylookup" git push
i.e. when I pull those changes on my other machines will I have the new version of pylookup?
Do I simply get my emacs repo to ignore
pylookup/*
and update it on every machine whenever pylookup is updated. This would get annoying if there was a few repo's and a few machines but I can live with it.Is there some smart tricks with
git submodule
. If so could you provide an explanation I didn't really understand the documentation. How would I pull changes for emacs and for pylookup.Do I go with answer 2 but make a script to update all sub-repos. If I did that I could run that once on each machine every time pylookup changed.
Couple of possible related posts.
If you create a Git submodule:
$ git submodule add git://github.com/tsgates/pylookup.git pylookup
$ git submodule init pylookup
$ git submodule update pylookup
Let's say there are some changes to pylookup and you want to get them:
$ cd pylookup
$ git pull origin master
$ cd ..
$ git add pylookup
$ git commit -m "Track new commit of pylookup"
这篇关于如何组合两个单独的Git存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!