我有两个 git 存储库,它们应该保持同步并且不能同时访问。一个在工作,一个在家里,没有网络连接。
如何处理这个简单的设置?
我尝试过的:
我有一个克隆,它“知道”存储库并存在于便携式硬盘上。
假设有人在“工作”创建了一个新分支,我想将它转移到回购“家”。这该怎么做?
如果我只做一个,git pull我会在我的克隆上得到以下内容:
$ git branch --list --all
*master
origin/HEAD -> origin/master
origin/bugfix_component_condition_destruction_fail
origin/master
origin/remove_stoplist_copy_and_erase
Run Code Online (Sandbox Code Playgroud)
问:这是否仅意味着我的本地克隆“知道”某处有这些列出的分支,并且除了本地存在的名为“master”的分支之外,我的克隆上没有真实数据?
很容易将 master 拉/推到两个 repos。但是我的本地克隆中似乎不存在任何其他人。我是否必须将每个远程分支跟踪到我克隆的本地分支,然后将其传输到另一个存储库?
问:如果将推送两个 repos 提交,是否有任何典型的方法来处理两个 repos 以使它们同步?
问:有没有什么技巧可以获取所有远程分支的所有信息和内容。
对我来说,回购的“克隆”意味着什么有点神秘?它似乎不是真正的克隆,而只是一些元数据和主分支。这是正确的吗?
编辑:
如果我开始,gitk --all我会看到在分支中完成的所有更改。看起来分支的内容在克隆中。
但如果我这样做:
$git checkout -b remove_stoplist_copy_and_erase --track remotes/origin/remove_stoplist_copy_and_erase
error: Not tracking: ambiguous information for ref refs/remotes/origin/remove_stoplist_copy_and_erase
Switched to a new branch 'remove_stoplist_copy_and_erase'
Run Code Online (Sandbox Code Playgroud)
所以我做了:
$git checkout origin/remove_stoplist_copy_and_erase
$git checkout -b remove_stoplist_copy_and_erase
Run Code Online (Sandbox Code Playgroud)
现在推送它: $git push --set-upstream ex remove_stoplist_copy_and_erase
我担心必须为两个遥控器上的所有分支手动执行所有这些操作才能使两者同步。这项工作是否有一些“最佳实践”?
您可以为此使用捆绑包。无需在便携式磁盘上拥有完整的存储库
让我们称他们repo1与repo2
在 repo1 你调用:
$ git fetch <bundle2> 'refs/heads/*:refs/remotes/repo2/*' 从在 repo2 创建的包文件中导入更改$ git bundle create <bundle1> --all --not --remotes=repo2 创建一个用于发送到 repo2 的包在 repo2,相应地:
$ git fetch <bundle1> 'refs/heads/*:refs/remotes/repo1/*' 和$ git bundle create <bundle2> --all --not --remotes=repo1该手册页包含更多的信息和示例。
| 归档时间: |
|
| 查看次数: |
5197 次 |
| 最近记录: |