我如何配置Git从一个仓库中提取并推送到另一个仓库? [英] How do I configure Git to pull from one repo and push to another?

查看:98
本文介绍了我如何配置Git从一个仓库中提取并推送到另一个仓库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我正在学习的课程克隆了一个公共GitHub回购(远程起源),并从中抽取我的任务。在我完成任务之后,我想将我的工作推到一个专用的BitBucket回购(远程bitbucket)上,该命令使用命令(假回购商名称)创建:

I've cloned a public GitHub repo [remote origin] for a class I'm taking and pull my assignments from it. After I do the assignments I'd like to push my work to a private BitBucket repo [remote bitbucket] which I created with the commands (fake repo name):

$ git remote add bitbucket https://neilostrove@bitbucket.org/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
$ 

现在,当我尝试从原点拉出时,我收到消息:

Now when I try to pull from origin I get the message:

$ 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.

我想设置一些东西,以便当我(或取)起源,当我推动一切都推到bitbucket。我怎么做到这一点?

I would like to set things up so that when I pull (or fetch) my repo gets updated from origin, and when I push everything is pushed to bitbucket. How can I do that?

这是我设置遥控器的方式:

This is how I have my remotes set up:

 $ git remote -v
 bitbucket       https://neilostrove@bitbucket.org/neilostrove/bb-repo.git (fetch)
 bitbucket       https://neilostrove@bitbucket.org/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远程。分支 .pushurl u:/ / r / l

git config remote.branch.pushurl u://r/l

git-config(1)手册页 git-push(1)手册页

这篇关于我如何配置Git从一个仓库中提取并推送到另一个仓库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆