git-merge 与本地文件系统上的存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1651985/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:55:18  来源:igfitidea点击:

git-merge with repository on local filesystem

gitgitosisgit-merge

提问by Ben Hymers

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).

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

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:

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

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/

... 哪里有 git 存储库~/gitosis-admin-old/~/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!

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

回答by Jakub Nar?bski

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

您需要git pull与存储库一起使用,而不是git merge(用于分支):

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 addlike in jamessan answeris 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 remote addjamessan answer 中使用like是不必要的工作。另一方面,如果您要重新访问遥控器(拉动多次),则此解决方案比使用git pull <location> <branch>.

回答by jamessan

You need to create a remote for that repository and then fetch & merge (or simply pull) from there.

您需要为该存储库创建一个远程,然后从那里获取和合并(或简单地拉取)。

git remote add admin-old file://$HOME/gitosis-admin-old
git pull admin-old