【问题标题】:why i cannot push mirror to github?为什么我不能将镜像推送到 github?
【发布时间】:2012-09-03 04:27:25
【问题描述】:

我可以使用同步源

git fetch origin

我在 master 分支上,origin 是一个裸仓库。

我也可以运行将更改推送到 github:

git push github  --all
git push github --tags

但是为什么使用 git fetch origin 获取的最新提交无法推送到 github?

当我推送时,git 只会回复: 一切都是最新的

这意味着实际上没有发生推送 :( 因为从 origin 获取的最新提交没有推送到 github,为什么?

//这是本地镜像,我想推到github上

[core]
        repositoryformatversion = 0
        filemode = true
        bare = true
[remote "origin"]
        fetch = +refs/*:refs/*
        mirror = true
        url = http://git.mirror.xxx.xx/xxx/root.git
[remote "github"]
        url = git@github.com:username/xxx.git
        fetch = +refs/heads/*:refs/remotes/github/*

【问题讨论】:

    标签: git version-control github git-push


    【解决方案1】:

    git fetch 将获取origin 的所有远程跟踪分支。

    但是,如果这些新提交与您当前的本地分支无关,git push github 将不会更新有关所述(已经是最新的)当前分支的任何内容。
    (取决于current git push policy 和你的 git 版本)

    您可以尝试git push --mirror github,以便将所有参考推送到 GitHub。
    但您需要先从 github fetch 分支:git fetch github,以便您的本地仓库了解所述匹配分支。

    【讨论】:

    • 如何知道提交与我当前的本地分支有关?为什么 git push --all 不能推送?
    • @thinke365 git push --all 将遵循默认推送策略(matching,直到 git2.0):如果您没有 github 远程 repo 的远程跟踪分支,它将不会推送任何内容.另一方面,git push --mirror 如下:“新创建的本地 refs 将被推送到远程端,本地更新的 refs 将在远程端强制更新”(git-scm.com/docs/git-push
    • @thinke365 'git branch -a' 将列出所有分支(远程跟踪和本地)。
    • 如果你没有 github 远程 repo 的远程跟踪分支,这意味着什么?
    • @thinke365 这意味着您可能必须明确推送这些分支 (stackoverflow.com/questions/1519006/…),或者您需要先跟踪它们:stackoverflow.com/a/6300386/6309
    猜你喜欢
    • 2021-12-03
    • 1970-01-01
    • 2021-10-14
    • 1970-01-01
    • 2022-01-27
    • 2022-11-25
    • 1970-01-01
    • 2021-11-22
    • 2021-08-17
    相关资源
    最近更新 更多