How to push from one bare git repo to another?

前端 未结 3 2081
野的像风
野的像风 2021-01-08 00:54

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 exchang

3条回答
  •  无人及你
    2021-01-08 01:32

    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.

提交回复
热议问题