推送到其他远程存储库

时间:2019-04-29 22:05:49

标签: git push git-remote

假设我有一个本地存储库 A ,而且我还可以访问远程存储库 B 。这些存储库完全不同!我想将所有文件/提交等...从 A 推送到 B 存储库。 所以我遵循了git命令:

  1. git remote add origin <my remote git url>
  2. git push origin master

我收到以下错误:

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.

出现问题的原因是,我不想执行git pull命令,因为 B 存储库占用了大量空间(数千兆字节!),而 A < / strong>存储库需要几千字节。

有没有推拉的方法吗?

1 个答案:

答案 0 :(得分:2)

在遥控器上创建一个新分支:

git push origin master:my-branch

然后,在远程上,您可能需要将工作添加到master分支。一种方法是:

git checkout my-branch
git rebase master
git checkout master
git merge my-branch