git - 如何配置 Git 从一个存储库 pull 并推送到另一个存储库?

标签 git github bitbucket

我已经为我正在参加的类(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-config(1) Manual Pagegit-push(1) Manual Page .

关于git - 如何配置 Git 从一个存储库 pull 并推送到另一个存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24814084/

相关文章:

github - 从 Google 搜索中删除 GitHub Profile 和 Repos

git - 使用 GitHub Pull Request Builder 触发多个 Jenkins 构建

git - 部署 ASP.Net MVC .Net Core 应用程序时出现错误 MSB4025

node.js - 使用 grunt、bower、node 模块部署到 heroku

git - 澄清 gitignore 文档

git - 如何从 GitHub 下载特定提交 sha 的 .zip?

java - 我应该如何将我的 intelliJ 项目添加到已经存在的 Github 存储库中?

Jenkins 将 302 返回到 bitbucket webhook

Git 错误 : conq: repository does not exist

python - 如何在 git 上构建多个函数以在 Google Cloud Functions 上自动部署?