我已经为我正在参加的类(class)克隆了一个公共(public) GitHub 存储库 [远程来源],并从中提取了我的作业。完成作业后,我想将我的工作推送到我使用命令创建的私有(private) BitBucket 存储库 [远程 bitbucket](假存储库名称):
$ git remote add bitbucket https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7a141f131615090e08150c1f3a18130e180f19111f0e5415081d" rel="noreferrer noopener nofollow">[email protected]</a>/neilostrove/bb-repo.git
$ git push -u bitbucket --all
Password:
Counting objects: 2856, done.
...
Branch master set up to track remote branch master from bitbucket.
Branch work set up to track remote branch work from bitbucket.
$ git push -u bitbucket --tags
Password:
Everything up-to-date
$
现在,当我尝试从原点 pull 时,我收到消息:
$ git pull origin
You asked to pull from the remote 'origin', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.
我想进行一些设置,以便当我 pull (或获取)我的存储库时,它会从原始位置更新,并且当我推送时,所有内容都会被推送到 bitbucket。我怎样才能做到这一点?
这就是我设置 Remote 的方式:
$ git remote -v
bitbucket https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9ff1faf6f3f0ecebedf0e9fadffdf6ebfdeafcf4faebb1f0edf8" rel="noreferrer noopener nofollow">[email protected]</a>/neilostrove/bb-repo.git (fetch)
bitbucket https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6b050e020704181f19041d0e2b09021f091e08000e1f4504190c" rel="noreferrer noopener nofollow">[email protected]</a>/neilostrove/bb-repo.git (push)
origin https://github.com/instructor/gh-repo.git (fetch)
origin https://github.com/instructor/gh-repo.git (push)
最佳答案
这种用法很常见,有一个配置项:
git config remote.<em>branch</em>.pushurl u://r/l
关于git - 如何配置 Git 从一个存储库 pull 并推送到另一个存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24814084/