git与本地文件系统上的存储库合并 [英] git-merge with repository on local filesystem

查看:95
本文介绍了git与本地文件系统上的存储库合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于某些情况:我刚升级了Ubuntu,这打破了我现有的gitosis安装(请参阅: bug#368895 ),并刚从包中重新安装gitosis。我现在想从旧的gitosis安装中迁移我的整个配置和一组存储库(它仍然存在,可以从中取出,但是被破坏)。

我现在有本地两个gitosis-admin目录,每个gitosis安装一个。一个有完整的历史,另一个是空的。我想拉过这段历史。以下是所发生的事情:

  me @ server:〜/ gitosis-admin-new $ git merge ../gitosis-admin-旧/ 
致命:'../gitosis-admin-old/'不指向提交

... 〜/ gitosis-admin-old / 〜/ gitosis-admin-new /



我可能需要为其他存储库执行此操作,这些存储库具有更长和更重要的历史记录,因此需要复制提交作为一个不是一个选项。



我做错了什么?我已经尝试指向.git / HEAD,据我了解这是一个提交,但这不起作用。有人可以解释如何做到这一点?感谢!

解决方案

您需要在存储库中使用 git pull git merge (这是分支机构):

  git pull .. / gitosis-admin-old / 

您可能需要在远程合并中选择一个分支,例如:

  git pull ../gitosis-admin-old/ master 

如果你只需要合并一次,那么在 git remote add https://stackoverflow.com/questions/1651985/git-merge-with-repository-on-local-filesystem/1652052#1652052\">贾米森答案是不必要的工作。另一方面,如果你要重新访问远程(拉多次),这个解决方案会比使用 git pull< location>更好。 < branch>


For some context: I just upgraded Ubuntu which broke my existing gitosis installation (see here: bug #368895), and have just reinstalled gitosis from packages. I now want to migrate my whole config and set of repositories from the old gitosis installation (which still exists and can be pulled from but is otherwise broken).

I now have two gitosis-admin directories locally, one for each gitosis installation. One has a full history, the other's is empty. I want to pull across this history. Here's what's happening though:

me@server:~/gitosis-admin-new$ git merge ../gitosis-admin-old/
fatal: '../gitosis-admin-old/' does not point to a commit

... where there is are git repositories in ~/gitosis-admin-old/ and ~/gitosis-admin-new/

I'm probably going to need to do this for the other repositories too, which have much longer and more important histories, so copying and committing as one is not an option.

What am I doing wrong? I've tried pointing to .git/HEAD which as I understand is a commit, but that doesn't work. Could someone explain how to do this? Thanks!

解决方案

You need to use git pull with repository, not git merge (which is for branches):

git pull ../gitosis-admin-old/

You might need to select a branch in remote to merge, e.g.:

git pull ../gitosis-admin-old/ master

If you need to do this merge only once, then using git remote add like in jamessan answer is unnecessary work. On the other hand if you would be revisiting the remote (pulling more than one time), this solution would be better than using git pull <location> <branch>.

这篇关于git与本地文件系统上的存储库合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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