为什么我不能推到这个裸仓库? [英] Why can't I push to this bare repository?

查看:106
本文介绍了为什么我不能推到这个裸仓库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $ git init --bare bare 
初始化为空Git仓库在/ work / fun / git_experiments / bare /
$ git克隆裸爱丽丝
克隆到爱丽丝...
完成。
警告:您似乎已经克隆了一个空的存储库。
$ cd alice /
$ touch a
$ git add a
$ git commit -m添加了
[master(root-commit)70d52d4] Added一个
0文件被改变,0个插入(+),0个删除( - )
创建模式100644 a
$ git push
没有共同的引用和没有指定;什么也不做。
也许你应该指定一个分支,比如'master'。
致命:远程端意外挂起
错误:未能将某些文件推送到'/ work / fun / git_experiments / bare'

不是 git push 总是推送到我克隆的存储库中?

是的,问题是没有裸提交。如果您按顺序创建仓库(裸设备,alice),则仅第一次提交时会出现问题。尝试做:

  git push --set-upstream origin master 

这只是第一次需要。之后它应该能正常工作。



正如克里斯约翰森指出的,如果您的push.default是自定义的,您不会遇到这个问题。我喜欢上游/跟踪。

Can you explain what is wrong with this workflow?

$ git init --bare bare
Initialized empty Git repository in /work/fun/git_experiments/bare/
$ git clone bare alice
Cloning into alice...
done.
warning: You appear to have cloned an empty repository.
$ cd alice/
$ touch a
$ git add a
$ git commit -m "Added a"
[master (root-commit) 70d52d4] Added a
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 a
$ 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 '/work/fun/git_experiments/bare'

Doesn't git push always push to the repository I cloned from?

解决方案

Yes, the problem is that there are no commits in "bare". This is a problem with the first commit only, if you create the repos in the order (bare,alice). Try doing:

git push --set-upstream origin master

This would only be required the first time. Afterwards it should work normally.

As Chris Johnsen pointed out, you would not have this problem if your push.default was customized. I like upstream/tracking.

这篇关于为什么我不能推到这个裸仓库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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