我检查了一个远程分支,git checkout -b newBranch origin/some-remote-branch但是每当我进行推送时,它都会被推送到一个新分支newBranch。如何告诉 git 自动推送到我从 origin 签出的分支?
2 回答
            2        
        
		
git push origin newBranch:some-remote-branch
或者,如果您希望它在运行时自动执行git push,请编辑您的条目,.git/config如下所示
[branch "newBranch"]
    remote = origin
    merge = refs/heads/some-remote-branch
您也可以运行而不是手动git branch -u origin/some-remote-branch newBranch编辑。.git/config
并确保您还具有以下设置,以便推送默认推送到上游(现在,默认是推送到匹配的分支名称):
[push]
    default = upstream
您可以运行git config push.default upstream来设置它,或者git config --global push.default upstream如果您想为所有存储库全局设置此选项。
于 2013-10-21T13:56:59.137   回答
    
    
            0        
        
		
如果只希望分支推送到特定的远程分支,则需要将上游分支设置为git branch -u origin/some-remote-branch. 然后你只需要运行git push
如果它总是推到newBranch,我认为你正在这样做git push origin newBranch。此命令将一个新的远程分支newBranch推送到原点。  
于 2013-10-21T14:00:26.263   回答