如何配置Git从一个仓库拉出并推送到另一个仓库?

时间:2014-07-17 21:45:22

标签: git github bitbucket

我已经克隆了一个公共GitHub回购[远程来源]我正在上课并从中提取我的作业。在我完成作业之后,我想将我的作品推送到我用命令创建的私人BitBucket repo [remote bitbucket](假回购名称):

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

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

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

我想设置一下,这样当我拉(或获取)时,我的repo会从原点更新,当我推送时,所有内容都会被推送到bitbucket。我怎么能这样做?

这就是我设置遥控器的方法:

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

1 个答案:

答案 0 :(得分:2)

这种用法很常见,有一个配置项:

  

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

git-config(1) Manual Pagegit-push(1) Manual Page上的文档。