为什么我可以从一些跟踪分支而不是其他分支?

时间:2012-04-27 22:30:47

标签: git git-push

Windows 7上的Git - git版本1.7.3.1.msysgit.0。

我的公司在Git存储库中有多个项目(如果重要的话,在GitHub上)。

对于其中一些我创建本地跟踪分支(例如git push -u origin mybranch--set-upstream origin/mybranch)时,我可以使用git pull&来拉动并推送到该分支。分别git push,一切正常。

但是在其他情况下(其他项目),当我尝试相同的场景时,我可以拉(git pull),但是当我推动时我必须指定原点和分支 - 例如git push origin mybranch。只要做git push就会返回'Everything up-date',即使它不是,也没有推动我想要的更改。

以下是git remote show origin&的输出。 cat .git/config表示有效的存储库和不存在的存储库。

我注意到两件事:

  1. 在有效的那个中,p1_branch显示了push&拉出远程节目输出中的条目。但对于没有的那个,p2_branch只有一个pull条目。但我不知道为什么会这样。它们的设置方式相同。

  2. 一个设置为合并,另一个设置为rebase。我在存储库中运行git config branch.master.rebase true但是没有工作,而不是另一个。我认为这解释了这种差异,但不明白它是否会导致这个问题。

  3. 作品(project1):

    $ git remote show origin
    * remote origin
      Fetch URL: git@github.com:MyCompany/project1.git
      Push  URL: git@github.com:MyCompany/project1.git
      HEAD branch: master
      Remote branches:
        master       tracked
        p1_branch    tracked
      Local branches configured for 'git pull':
        master       merges with remote master
        p1_branch    merges with remote p1_branch
      Local refs configured for 'git push':
        master       pushes to master  (up to date)
        p1_branch    pushes to p1_branch (up to date)
    
    $ cat .git/config
    [core]
            -- same for both repositories --
    [remote "origin"]
            fetch = +refs/heads/*:refs/remotes/origin/*
            url = git@github.com:MyCompany/project1.git
    [branch "master"]
            remote = origin
            merge = refs/heads/master
    [branch "p1_branch"]
            remote = origin
            merge = refs/heads/p1_branch
    
    

    不起作用(project2):

    $ git remote show origin
    * remote origin
      Fetch URL: git@github.com:MyCompany/project2.git
      Push  URL: git@github.com:MyCompany/project2.git
      HEAD branch: master
      Remote branches:
        -- cut a bunch of tracked branches entries --
        master       tracked
        ...
        p2_branch    tracked
        ...
      Local branches configured for 'git pull':
        master     rebases onto remote master
        p2_branch  rebases onto remote p2_branch
      Local ref configured for 'git push':
        master     pushes to master (up to date)        
    
    $ cat .git/config
    [core]
            -- same for both repositories --
    [remote "origin"]
            fetch = +refs/heads/*:refs/remotes/origin/*
            url = git@github.com:MyCompany/project2.git
    [branch "master"]
            remote = origin
            merge = refs/heads/master
            rebase = true
    [submodule ...]
            -- cut a bunch of submodule stuff --
    [merge]
            conflictstyle = diff3
    [branch]
            autosetuprebase = always
    [branch "p2_branch"]
            remote = origin
            merge = refs/heads/p2_branch
            rebase = true
    

0 个答案:

没有答案