git push:refs / heads / my / subbranch存在,无法创建 [英] git push: refs/heads/my/subbranch exists, cannot create

查看:678
本文介绍了git push:refs / heads / my / subbranch存在,无法创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是不可能在服务器上的回购库中创建somme子子文件夹的吗?



如果我这样做:

  git push origin dev / master 

所有工作都可以找到

但是如果我做

  git push origin dev / sub / master 

我得到这个:

 错误:'refs / heads / dev / sub'存在;无法创建'refs / heads / dev / sub / master'

我用git branch -r 并直接使用ssh,没有创建dev / sub文件夹。



有什么不对?

解决方案

它不是存在的文件夹,它是分支。 (好吧,可能有某个文件夹/目录涉及某处 - 或者可能不是,因为引用会被打包并在目录中停止存在为文件。)


  • 如果分支 b 存在,则不能创建名为 b / anything 的分支。同样,如果分支 dev / b 存在,则 dev / b / c 无法创建。

  • 这是git内部限制。在这种特殊情况下,远程 origin 有一个名为 dev / sub 的分支(不管你是否拥有它,重要的是遥控器是否拥有它)。为了在 origin 上创建一个名为 dev / sub / master 的分支,您必须先删除名为< dev / sub 关于 origin

      git push origin:dev / sub 

    (当然,删除这个分支可能会在这里删除一些重要的东西,所以一定要知道你在做什么。一般来说,你可能首先需要 git fetch origin 来捕获它们的 dev / sub 作为你的 origin / dev / sub 。然后你可以创建一个名为 dev / renamed-sub 指向同一个提交,在远程创建 dev / renamed-sub ,删除远程 dev / sub dev / sub / master 。)




    如果您可以登录到远程系统( origin 位于其上的系统),那么您可以进入存储库并简单地重命名本地 dev / sub 分支。 (根据下面的评论,我怀疑那里也有一个破坏的自动部署脚本,这可能应该修复为只部署可部署的分支,而不是所有被推送的分支,但我只是在这里猜测。)


    Is this not possible to create somme sub-sub-folder in a repo on a server?

    if i do:

    git push origin dev/master 
    

    everything work find

    but if i do

    git push origin dev/sub/master
    

    i got this:

    error: 'refs/heads/dev/sub' exists; cannot create 'refs/heads/dev/sub/master'
    

    i checked with "git branch -r" and directly with ssh, there isn't dev/sub folder already created.

    what's wrong?

    解决方案

    It's not a folder that exists, it's a branch. (Well, there may be a folder/directory involved somewhere—or maybe not, as references get "packed" and stop existing as files within directories.)

    • If branch b exists, no branch named b/anything can be created.
    • Likewise, if branch dev/b exists, dev/b/c cannot be created.

    This is a git internal limitation. In this particular case, remote origin has a branch named dev/sub (regardless of whether you have it or not, the important thing is whether the remote has it). In order to create, on origin, a branch named dev/sub/master, you must first delete the branch named dev/sub on origin:

    git push origin :dev/sub
    

    (Of course, deleting this branch may delete something important over there, so be sure you know what you are doing. Generally, you might want to git fetch origin first, capturing their dev/sub as your origin/dev/sub. You can then make a local branch named dev/renamed-sub pointing to the same commit, create dev/renamed-sub on the remote, delete the remote dev/sub, and then create dev/sub/master on the remote.)


    If you can log in on the remote (the system that origin is hosted on), you can go into the repository over there and simply rename the local dev/sub branch. (Based on comments below, I suspect that there's a broken auto-deploy script over there as well, which probably should be fixed to only deploy "deployable" branches, rather than everything that gets pushed. But I am just guessing here.)

    这篇关于git push:refs / heads / my / subbranch存在,无法创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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