2012-05-21 268 views
0

我有一個遠程倉庫和一個本地倉庫。我做了git fetch --all,看到我想在本地倉庫分支,我想創建一個本地跟蹤分行:Git:如何推送本地分支重命名遠程分支?

git checkout -t -b bug1000 origin/user/bug/1000 

我的問題是,拉的都是正確的,但推的都沒有設置:

>$ git remote show origin 
* remote origin 
    Fetch URL: XXX 
    Push URL: XXX 
    HEAD branch: master 
    Remote branches: 
    maint          tracked 
    master          tracked 
    user/bug/1000        tracked 
    user/bug/1001        tracked 
    user/bug/1002        tracked 
    Local branches configured for 'git pull': 
    bug1000  merges with remote user/bug/1000 
    maint  merges with remote maint 
    master  merges with remote master 
    Local refs configured for 'git push': 
    maint  pushes to maint  (local out of date) 
    master  pushes to master  (local out of date) 

.git/config看起來是正確的:

[remote "origin"] 
     fetch = +refs/heads/*:refs/remotes/origin/* 
     url = XXX 
[branch "master"] 
     remote = origin 
     merge = refs/heads/master 
[branch "maint"] 
     remote = origin 
     merge = refs/heads/maint 
[branch "bug1000"] 
     remote = origin 
     merge = refs/heads/user/bug/1000 

我已經嘗試git push -u origin bug1000:user/bug/1000,但它不會改變任何東西。

這是使用git 1.7.10.2(作爲寫作時最新的穩定)。

回答

0

您可以添加對遠程一個push項,但如果你有很多的這些,可能很麻煩:

[remote "origin"] 
    fetch = +refs/heads/*:refs/remotes/origin/* 
    url = XXX 
    push = refs/heads/bug1000:refs/heads/user/bug/1000 

如果您添加了另一個虛擬的「目錄」,並使用bug/1000在本地而不是bug1000 ,那麼推送配置可能是push = refs/heads/bug/*:refs/heads/user/bug/*,從長遠來看這可能更清潔。

+0

我看着添加推送線,但實際上有很多分支要跟蹤。添加推線然後使我無法簡單地推送給主... – utopiabound

+1

請注意,您可以添加多個推送線,以便您可以使用與「正常」分支匹配的默認分支和特殊分支(或多個)來處理錯誤分支。 – twalberg