Git从一个回购拉出来并推向另一个回购

时间:2016-05-11 20:27:29

标签: git github push pull

我在github上有一个repo_1,有两个分支:mastergh-pages
然后我有一个带有单个分支的repo_2:master

可以从repo_1上的最新更新的gh-pages分支中提取并在repo_2上的master分支上推送它们吗?

更新

尝试此后

git pull repo_1 gh-pages
git push repo_2 gh-pages:master 

当我推到第二个回购时,我有这个错误:

! [rejected] gh-pages -> master (fetch first) error: 
   failed to push some refs to 'github.com/gnardel/gnardell.github.io.git';
   hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again.

1 个答案:

答案 0 :(得分:0)

错误

  

未能将某些参考文献推送到'github.com/gnardel/gnardell.github.io.git';   提示:更新被拒绝,因为遥控器包含您所做的工作

如果使用README和/或LICENSE文件初始化新的github存储库,则会发生这种情况,这是一个您本地没有的新提交。您需要先拉出并合并它:

git checkout gh-pages
git pull repo_2  master:gh-pages
# you may need to fix some merge conflicts
git push repo_2  gh-pages:master 

现在您可以将存储库推送到github。基本上,你必须在github上合并任何新的提交才能推送。