从 GitHub 分叉到 Bitbucket
我正在开发一个基于 CakePHP 的项目,该项目托管在 GitHub 上。 我的项目托管在Bitbucket上。他们都使用git。基本上我想在我的 Bitbucket 存储库中创建 CakePHP 的“分叉”(我不知道我是否使用了正确的术语,因为我是 git 新手),以便能够获取更新,而无需下载所有 CakePHP zip/tar 并替换文件夹,然后提交并推送,但可能需要“合并”(?)。
I'm working on a project based on CakePHP, that's hosted on GitHub. My project is being hosted on Bitbucket. Both of them use git. Basically I'd like to create a ‘fork’ (I don't know if I'm using the right terms, since I'm new to git) of CakePHP in my Bitbucket repository, in order to be able to get the updates without the need to download all the CakePHP zip/tar and replace the folder, then commit and push, but maybe with a ‘merge’(?).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
今天不可能跨不同站点发送“拉取请求”。我在 Bitbucket 问题跟踪器中添加了一个功能请求:#3288。如果您想跟踪此内容,我建议您将自己添加为关注者。
但是,您仍然可以将源代码从 GitHub 移至 Bitbucket,而无需下载任何 zip 文件或 tarball。您从 GitHub 进行克隆并推送到 Bitbucket:
我首先在 Bitbucket 中创建了
mg/cakephp
作为空的 Git 存储库。这样您就可以将变更集从 GitHub 推送/拉取到 Bitbucket。It's not possible to send "pull request" across different sites today. I've added a feature request for this in the Bitbucket issue tracker: #3288. I suggest you add yourself as a follower if you want to track this.
However, you can still move the source from GitHub to Bitbucket without having to download any zip files or tarballs. You make a clone from GitHub and push to Bitbucket:
I created
mg/cakephp
as an empty Git repository in Bitbucket first. That way you can push/pull changesets from GitHub to Bitbucket.下面的工作流程将 github 存储库添加为名为
sync
的新远程服务器,并将 bitbucket 远程服务器添加为origin
。它还添加了一个名为github
的分支来跟踪 github 存储库,以及一个名为master
的分支来跟踪 bitbucket 存储库。它假设您有一个名为“myrepository”的 bitbucket 存储库,该存储库是空的。设置远程
设置分支
现在您应该有本地
github
分支跟踪 github 存储库的master
分支。并且您应该有本地master
分支跟踪 bitbucket 存储库(默认情况下为master
分支)。这使得在
github
分支上进行拉取变得很容易,然后将这些更改合并到master
分支上(尽管 rebase 优先于合并),然后您可以推送master
分支(将其推送到 bitbucket)。The workflow below adds the github repository as a a new remote called
sync
and the bitbucket remote asorigin
. It also adds a branch calledgithub
to track the github repository and a branch calledmaster
to track the bitbucket repository. It assumes you have a bitbucket repository called "myrepository" which is empty.Setup remotes
Setup branches
Now you should have the local
github
branch tracking the github repo'smaster
branch. And you should have the localmaster
branch tracking the bitbucket repo (master
branch by default).This makes it easy to do a pull on the
github
branch, then merge those changes onto themaster
branch (rebase preferred over merge though) and then you can push themaster
branch (will push it to bitbucket).如果您想让您的存储库保持最新,请使用两个遥控器:Github(
上游
)和 Bitbucket(源
),如下所示:Github 提取 CakePHP 的更新:
要从 将代码更改推送到 Bitbucket:
If you want to keep your repo up to date, use two remotes: Github (
upstream
) and Bitbucket (origin
) like this:To pull updates to CakePHP from Github:
To push your code changes to Bitbucket:
在 BitBucket 中创建新存储库时,单击右上角的
导入存储库
按钮。输入在 Github 中单击克隆或下载
时找到的 https URL,获取您要分叉的存储库。为您的存储库命名,配置您的隐私设置,然后就可以了!
When creating a new repository in BitBucket, click the button
Import repository
at the top right. Enter the https url found when clickingClone or download
in Github for the repository you want to fork.Give your repository a name, configure your privacy settings, and there you go!
我注意到,自从 @Martin Geisler 的回答以来,Bitbucket 启用了从 github.com 导入存储库的功能,
我能够成功地将私有存储库从 github.com 导入到私有存储库中。 bitbucket.org 上的存储库
以下是步骤:
注意屏幕截图右上角的导入存储库链接
I have noticed that since @Martin Geisler 's answer, Bitbucket has enabled a feature to import repositories from github.com
I was able to successfully import a private repo from github.com into a private repo on bitbucket.org
Here are the steps:
Note the import repository link on right top corner of the screenshot
我猜您只是想轻松下载项目中的存储库...并且您不会贡献 cakePHP,对吗?
如果是这样,您只需向您的存储库添加外部引用即可。
SVN:GIT 中的外部等效项?
之后,即使您想为 cakePHP 做出贡献,您也可以可以在原始仓库中这样做就可以了。
I'm guessing you just want to easily download the repository with your project... and that you will NOT be contributing the cakePHP, correct?
if so, you just need to add a external reference to your repo.
SVN:externals equivalent in GIT?
And later, even if you want to contribute to cakePHP, you can just do so at the original repo just fine.