首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >从GitHub到Bitbucket的分叉

从GitHub到Bitbucket的分叉
EN

Stack Overflow用户
提问于 2011-11-15 22:35:59
回答 6查看 68.7K关注 0票数 174

我正在做一个基于CakePHP的项目,该项目托管在GitHub上。我的项目托管在Bitbucket上。它们都使用git。基本上,我想在我的Bitbucket存储库中创建一个CakePHP的“分支”(我不知道我是否使用了正确的术语,因为我是git新手),以便能够获得更新,而不需要下载所有的CakePHP压缩包并替换文件夹,然后提交和推送,但可能需要一个“合并”(?)。

EN

回答 6

Stack Overflow用户

回答已采纳

发布于 2011-12-11 20:18:33

现在不可能跨不同的站点发送“拉取请求”。我已经在Bitbucket问题跟踪器中添加了一个特性请求:#3288。如果你想跟踪这篇文章,我建议你将自己添加为追随者。

但是,您仍然可以将源代码从GitHub移动到Bitbucket,而不必下载任何压缩文件或tarball。你从GitHub创建一个克隆并推送到Bitbucket:

$ git clone https://github.com/cakephp/cakephp
$ cd cakephp
$ git push git@bitbucket.org:mg/cakephp.git master

我首先在Bitbucket中将mg/cakephp创建为一个空的Git存储库。这样,您就可以将变更集从GitHub推送到Bitbucket。

票数 150
EN

Stack Overflow用户

发布于 2013-02-27 14:46:59

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

安装程序远程

# setup local repo
mkdir myrepository
cd myrepository
git init

# add  bitbucket remote as "origin"
git remote add origin ssh://git@bitbucket.org/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优先于merge ),然后您可以推送master分支(会将其推送到bitbucket)。

票数 91
EN

Stack Overflow用户

发布于 2013-01-25 13:52:09

如果您想让您的存储库保持最新,请使用两个远程: Github (upstream)和Bitbucket (origin),如下所示:

# 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
票数 34
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8137997

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档