0

假设我有一个本地存储库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存储库占用了几千字节。

有什么方法可以不用拉就推吗?

4

1 回答 1

2

在远程创建一个新分支:

git push origin master:my-branch

然后,在远程,您可能希望将您的工作添加到主分支。一种方法是:

git checkout my-branch
git rebase master
git checkout master
git merge my-branch
于 2019-04-29T22:24:32.727 回答