Git:哪个是分支默认配置的远程? [英] Git: which is the default configured remote for branch?

查看:946
本文介绍了Git:哪个是分支默认配置的远程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个远程裸仓库 hub 。我只在 master 分支中工作。
下面这条错误消息的最后一句让我想知道:我如何知道哪一个是当前分支的默认配置远程?如何设置它?

  [myserver]〜/ progs $ git remote -v 
hub〜/ sitehub /progs.git/(fetch)
hub〜/ sitehub / progs.git /(push)

[myserver]〜/ progs $ git branch -r
hub / master
$ b $ [myserver]〜/ progs $ cat .git / HEAD
ref:refs / heads / master
$ b $ [myserver]〜/ progs $ git pull hub
您要求从远程'枢纽'拉,但没有指定
a分支。因为这不是您当前分支的默认配置远程
,所以您必须在命令行上指定一个分支。


解决方案

追踪远程分行

您可以使用git-branch的跟踪选项指定默认的远程存储库以进行推送和拉取。您通常在创建本地主分支时通过指定--track选项来完成此操作,但由于它已经存在,我们只需手动更新配置,如下所示:



编辑您的 .git / config

  [branchmaster] 
remote = origin
merge = refs / heads / master

现在你可以只需git push和git pull。



[ source ]


I have a remote bare repository hub. I work only in the master branch. The last sentence of this error message below makes me wonder: How do I find out which is the "default configured remote for your current branch"? And how do I set it?

[myserver]~/progs $ git remote -v
hub     ~/sitehub/progs.git/ (fetch)
hub     ~/sitehub/progs.git/ (push)

[myserver]~/progs $ git branch -r
  hub/master

[myserver]~/progs $ cat .git/HEAD
ref: refs/heads/master

[myserver]~/progs $ git pull hub
You asked to pull from the remote 'hub', 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.

解决方案

Track the remote branch

You can specify the default remote repository for pushing and pulling using git-branch’s track option. You’d normally do this by specifying the --track option when creating your local master branch, but as it already exists we’ll just update the config manually like so:

Edit your .git/config

[branch "master"]
  remote = origin
  merge = refs/heads/master

Now you can simply git push and git pull.

[source]

这篇关于Git:哪个是分支默认配置的远程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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