从 GitHub 分叉到 Bitbucket

发布于 2024-12-15 19:04:54 字数 289 浏览 1 评论 0原文

我正在开发一个基于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

记忆消瘦 2024-12-22 19:04:54

今天不可能跨不同站点发送“拉取请求”。我在 Bitbucket 问题跟踪器中添加了一个功能请求:#3288。如果您想跟踪此内容,我建议您将自己添加为关注者。

但是,您仍然可以将源代码从 GitHub 移至 Bitbucket,而无需下载任何 zip 文件或 tarball。您从 GitHub 进行克隆并推送到 Bitbucket:

$ git clone https://github.com/cakephp/cakephp
$ cd cakephp
$ git push [email protected]:mg/cakephp.git master

我首先在 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:

$ git clone https://github.com/cakephp/cakephp
$ cd cakephp
$ git push [email protected]:mg/cakephp.git master

I created mg/cakephp as an empty Git repository in Bitbucket first. That way you can push/pull changesets from GitHub to Bitbucket.

小伙你站住 2024-12-22 19:04:54

下面的工作流程将 github 存储库添加为名为 sync 的新远程服务器,并将 bitbucket 远程服务器添加为 origin。它还添加了一个名为 github 的分支来跟踪 github 存储库,以及一个名为 master 的分支来跟踪 bitbucket 存储库。它假设您有一个名为“myrepository”的 bitbucket 存储库,该存储库是空的。

设置远程

# setup local repo
mkdir myrepository
cd myrepository
git init

# add  bitbucket remote as "origin"
git remote add origin ssh://[email protected]/aleemb/myrepository.git

# add github remote as "sync"
git remote add sync https://github.com/aleemb/laravel.git

# verify remotes
git remote -v
# should show fetch/push for "origin" and "sync" remotes

设置分支

# first pull from github using the "sync" remote
git pull sync

# setup local "github" branch to track "sync" remote's "master" branch
git branch --track github sync/master

# switch to the new branch
git checkout github

# create new master branched out of github branch
git checkout -b master

# push local "master" branch to "origin" remote (bitbucket)
git push -u origin master

现在您应该有本地 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 as origin. It also adds a branch called github to track the github repository and a branch called master to track the bitbucket repository. It assumes you have a bitbucket repository called "myrepository" which is empty.

Setup remotes

# setup local repo
mkdir myrepository
cd myrepository
git init

# add  bitbucket remote as "origin"
git remote add origin ssh://[email protected]/aleemb/myrepository.git

# add github remote as "sync"
git remote add sync https://github.com/aleemb/laravel.git

# verify remotes
git remote -v
# should show fetch/push for "origin" and "sync" remotes

Setup branches

# first pull from github using the "sync" remote
git pull sync

# setup local "github" branch to track "sync" remote's "master" branch
git branch --track github sync/master

# switch to the new branch
git checkout github

# create new master branched out of github branch
git checkout -b master

# push local "master" branch to "origin" remote (bitbucket)
git push -u origin master

Now you should have the local github branch tracking the github repo's master branch. And you should have the local master 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 the master branch (rebase preferred over merge though) and then you can push the master branch (will push it to bitbucket).

驱逐舰岛风号 2024-12-22 19:04:54

如果您想让您的存储库保持最新,请使用两个遥控器:Github(上游)和 Bitbucket(),如下所示:

# Clone original CakePHP source code from Github
git clone --mirror https://github.com/cakephp/cakephp
cd cakephp
# Rename remote from `origin` to `upstream`
git remote rename origin upstream
# Add your Bitbucket repo (this is where your code will be pushed)
git remote add origin https://bitbucket/your/repo.git
# Push everything to Bitbucket
git push --mirror origin

Github 提取 CakePHP 的更新:

git pull upstream master

要从 将代码更改推送到 Bitbucket:

git push origin master

If you want to keep your repo up to date, use two remotes: Github (upstream) and Bitbucket (origin) like this:

# Clone original CakePHP source code from Github
git clone --mirror https://github.com/cakephp/cakephp
cd cakephp
# Rename remote from `origin` to `upstream`
git remote rename origin upstream
# Add your Bitbucket repo (this is where your code will be pushed)
git remote add origin https://bitbucket/your/repo.git
# Push everything to Bitbucket
git push --mirror origin

To pull updates to CakePHP from Github:

git pull upstream master

To push your code changes to Bitbucket:

git push origin master
国产ˉ祖宗 2024-12-22 19:04:54

在 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 clicking Clone or download in Github for the repository you want to fork.

Give your repository a name, configure your privacy settings, and there you go!

半衬遮猫 2024-12-22 19:04:54

我注意到,自从 @Martin Geisler 的回答以来,Bitbucket 启用了从 github.com 导入存储库的功能

能够成功地将私有存储库从 github.com 导入到私有存储库中。 bitbucket.org 上的存储库

以下是步骤

  1. 单击“创建”按钮并选择“存储库”(“+”>“存储库”)
  2. ,而不是立即创建新存储库从弹出的模式右上角选择导入存储库。
  3. 在新模式上填写 github 存储库的 URL 和身份验证凭据以导入存储库。
  4. 就是这样。一切顺利地从 github 导入到 bitbucket 中。

注意屏幕截图右上角的导入存储库链接

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:

  1. Click on the Create button and select Repository ('+' > Repository)
  2. Now, instead of creating a new repository select a import repository from the top right corner of the modal that pops up.
  3. fill in your github repo's URL and your authentication credentials on the new modal for importing the repository.
  4. That's it. Everything imports into bitbucket from github smoothly.

Note the import repository link on right top corner of the screenshot

枫以 2024-12-22 19:04:54

我猜您只是想轻松下载项目中的存储库...并且您不会贡献 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文