如何从一个裸git回购推到另一个? [英] How to push from one bare git repo to another?

查看:171
本文介绍了如何从一个裸git回购推到另一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和一个来自一个大团队的其他人正在为这个项目设计一个单独的页面。我们称它为组页面。当我们在组页面上工作时,我们需要交换不完整的代码,我们不希望将代码发送到中央仓库。在此期间,我们也在处理与组页面无关的功能,我们需要提交并推送到中央服务器。我正在考虑解决这个问题,这里是我的想法。请评论他们。



我们不能在实际的回购服务器上建立一个分支,因为这个回升服务器较高。


  1. 创建并通过电子邮件发送差异,然后在我们需要返回组页面时丢失更改并使用差异。获取电子邮件的人应用差异。等等。

  2. 我们对代码进行更改,提交它,但不要推送它。那么谁需要那些不完整的代码,就可以直接从我们这里拉。

  3. 使用--bare标志对中央服务器进行另一次克隆。所以我们可以把它作为一个本地中央服务器,只是为了组页面。我们可以从中拉出并为组页面创建单独的工作区。我们可以推动它。

现在每个都有问题。


  1. 太乏味了。我想为它使用git。

  2. 当有人从我身上拉出来,然后制作一个新功能,然后他推送(到中央服务器),然后他从我那里拿的任何东西都不会被推到服务器。当我们的组页码完成时,他如何最终将它推送到服务器。

  3. 同样的问题。有没有一种方法可以将本地中央服务器推送到主服务器?两者当然都是裸回购。有没有办法从一个裸克隆推送到主github回购?


解决方案

3是你最好的选择。事实上,这就是Git如何使用的原因;包含各个组件的存储库,这些存储库在完成工作后会进入更加中央的存储库。

推送其他人的更改没有任何问题。比方说,你做了一个改变,并将其推送到组页面存储库。然后我拉动它,做一些改变,然后推回去。现在我们决定我们完成了。如果我推送到中央存储库,那么推送将包括我的更改和我所做的更改所基于的更改。



您不需要从一个裸回购到另一个。 Git通过从本地回购推动到一个或多个远程回购。克隆时,会有一个名为origin的默认远程回购站。但是,您可以根据需要配置尽可能多的远程回购站。为了设置这个,假设你已经从中央回购中克隆出来;这就是所谓的起源。现在您创建一个裸回购:它位于 ssh://some-machine.corp.com/path/to/groups-repo.git 。在你当地的工作仓库里,只要执行 git remote add groups ssh://some-machine.corp.com/path/to/groups-repo.git ,你会参考那些团体回购。现在你可以使用 git fetch git pull , git push 等等 groups 以及 origin


Me and a couple of other guys from a big team are working on a separate page on the project. Let's call it groups page. While we work on the groups page, we need to exchange incomplete code, the code we wouldn't want to be sent to the central repo. And during this time, we also work on features not related to groups page, we do need to commit and push to the central server. I am looking at solutions for this problem, here are my ideas. Please comment on them.

We can't make a branch in the actual repo server because of the higher ups.

  1. Create and email diffs to each other, then lose changes and use the diff when we need to go back to groups page. The person getting the emails applies the diff. etc.
  2. We make a change to our code, commit it, but don't push it. Then whoever needs that incomplete code, can pull from us directly.
  3. Make another clone of the central server with --bare flag. So we can treat it as a local-central server just for the groups page. We can pull from it and create a separate workspace for groups page. We can push and pull to it.

Now each of these has problems.

  1. is too tedious. I wanna use git for it.
  2. When someone has pulled from me, and then worked on a new feature, and then he pushes (to the central server), then whatever he pulled from me doesn't get pushed to the server. How would he finally push it to the server when our groups page code is complete.
  3. The same problem. Is there a way I push from this local-central server to the main server? Both are bare repos of course. Is there a way to push from one bare clone to the main github repo?

解决方案

3 is your best option. In fact, that's really how Git is intended to be used; with repositories for individual components, which feed into a more central repository when work is done.

There is no problem pushing someone else's changes. Lets say you make a change, and push it to the groups page repository. Then I pull that, make some changes, and push them back. Now we decide we're done. If I push to the central repository, that push will include both my changes, and your changes which my changes were based on.

You do not need to push from one bare repo to another. Git works by pushing from your local repo, to one or more remote repos. When you clone, there's a default remote repo called "origin". But you can have as many remote repos configured as you want. To set this up, let's say you have cloned from the central repo; that's called "origin". Now you create a bare repo: it's at ssh://some-machine.corp.com/path/to/groups-repo.git. In your local working repo, just do git remote add groups ssh://some-machine.corp.com/path/to/groups-repo.git, and you will have a reference to that groups repo. Now you can use git fetch, git pull, git push and so on with groups as well as with origin.

这篇关于如何从一个裸git回购推到另一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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