gitolite:新存储库的默认遥控器 [英] gitolite: default remotes for new repository

查看:108
本文介绍了gitolite:新存储库的默认遥控器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了gitolite(现在本地进行实验),它似乎能够工作,除了在git克隆后默认情况下,新的存储库不会跟踪远程设备。如果我没有记错的话,当我从github.com克隆一个仓库时,它已经能够推拉。

I've installed gitolite (locally for now, to experiment) and it seems to work, except that new repositories are not tracking the remote by default after a git clone. If I remember correctly, when I clone a repository from github.com, it's already able to push and pull.

这是我试过的:

$ git clone git@localhost:sandbox
Cloning into sandbox...
warning: You appear to have cloned an empty repository.
$ echo "A" > README
$ git add README
$ git commit README -m 'test'
$ git push
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'git@localhost:sandbox'

当我试图明确推送一切工作时:

When I try to push explicitly everything works:

$ git push origin master
Counting objects: 6, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (6/6), 426 bytes, done.
Total 6 (delta 0), reused 0 (delta 0)
To git@localhost:sandbox
 * [new branch]      master -> master

这个额外步骤真的需要吗?可以默认设置?在github上它是,不是吗?

谢谢

Is this additional step really needed? Can be set by default? On github it is, isn't?

推荐答案

第一个git push总是需要指定你想推送的分支。

解决方案
The first git push always require to specify the branch you want to push. 

然后,可以按照您的意图从同一分支完成下一个推送:

git push -u origin master

Then the next push can be done, from the same branch, as you intended:

From git push 手册页

git push


特殊refspec (或 +:快进更新)指示git推送匹配分支:对于存在于本地端的每个分支,如果远程端已存在相同名称的分支,则更新远程端。

如果未找到明确的refspec,则这是默认操作模式。

From git push man page:

由于您已经克隆了一个空的存储库,第一次推送没有找到任何匹配的分支(没有在上游回购'原产地')

The special refspec : (or +: to allow non-fast-forward updates) directs git to push "matching" branches: for every branch that exists on the local side, the remote side is updated if a branch of the same name already exists on the remote side.
This is the default operation mode if no explicit refspec is found.

注意:请参阅 git push origin

Since you have cloned an empty repository, the first push doesn't find any matching branch (there is none on the upstream repo 'origin')

c $ c $?

Note: See "What is the result of git push origin?":

git push的默认策略会随着git 2.0(或者可能是git1.9)而变化。
$ b

The default policy for git push will change with git 2.0 (or maybe git1.9)


一种新的推送模式, 简单 ,这是一个交叉介于当前上游之间。

git push 没有任何refspec会推送当前分支到远程仓库的相同名称,只有当它被设置为在那里跟踪具有相同名称的分支时当$ push.default 未配置时,计划将使此模式成为新的默认值。

A new mode for push, "simple", which is a cross between "current" and "upstream", has been introduced.
"git push" without any refspec will push the current branch out to the same name at the remote repository only when it is set to track the branch with the same name over there.
The plan is to make this mode the new default value when push.default is not configured.

所以在 git push -u origin master 中, -u - set-upstream-to )在这里非常重要(不仅仅是将具有相同名字的分支推送到远程' origin ',但它是一个远程追踪分支。

So in the git push -u origin master, the -u (--set-upstream-to) is important here (not just to push the branch with the same name to the remote 'origin', but it a remote tracking branch.

这篇关于gitolite:新存储库的默认遥控器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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