如何将存储库的分支放入新的存储库中?

时间:2019-03-08 22:58:10

标签: git github repository branch git-fork

我公司的团队A已经开发了一个应用程序框架,可以在https://git.mycompany.com/teama/theirproject上找到它。在theirproject下是dir1dir2file1file2

我的团队(团队B)希望使用该框架来实现应用程序。 A团队告诉我,我们必须派生他们的项目,并且必须使用特定的分支(我们将其称为branch1)。

我的团队希望在https://git.mycompany.com/teamb/ourproject上为我们的应用程序创建一个新的存储库。我们的仓库看起来就像团队A的仓库一样,因此在ourproject下,我们将像团队A一样拥有dir1dir2file1file2

如何将branch1的{​​{1}}分支派生到https://git.mycompany.com/teamb/ourproject中?可以完全从命令行完成它,还是需要从我们的GitHub Enterprise网站完成某些事情?

请注意,我什至还没有创建theirproject存储库(尽管我可以轻松地创建)。我是git新手,不确定是否有办法创建ourproject回购作为对ourproject的{​​{1}}进行分叉的一部分。

1 个答案:

答案 0 :(得分:1)

您可以将theirproject回购设置为ourproject回购中的上游,并为branch1回购中的theirproject设置跟踪分支。

1)设置ourproject回购,理想情况下为空。

2)克隆ourproject

3)添加theirproject作为上游。 git remote add their_upstream https://git.mycompany.com/teama/theirproject.git

4)安装程序集成分支。 git checkout -b incoming_branch

5)从their_upstream:branch1提取代码。 git pull their_upstream branch1

6)推送到您的仓库。 git push origin。第一次需要做git push origin --set-upstream incoming_branch

7)通过公关将incoming_branch合并到您的masterdevelop中。

8)重复5至7次。

奖金:您可以通过将代码推送到theirproject并在their_upstream:new_fw_feature回购中创建PR来将要贡献的代码推送回theirproject

希望这会有所帮助!

相关问题