2014-02-25 38 views
6

git和github的新手。合併分支後無法解析reference refs/refs/remotes/origin/branch

我想用本地和遠程的我的其他分支bridge替換git master分支。問題是git無法解析bridge分支的引用。問題出在推送到github上。

git的樹怎麼走過來的是這樣的:

  1. 通過Git的GUI啓動主分支。
  2. 繼續,然後意識到這並不是很好,並過渡到Bash。
  3. 由於本地主分支的尖端位於遠程對象的尖端後面,因此無法再推送給github以作爲master。
  4. 爲了規避,我創建了另一個叫做橋的分支。我不喜歡,我做了橋默認的,所以我又試圖用改回主:

     
    git checkout better_branch 
    git merge --strategy=ours master # keep the content of this branch, but record a merge 
    git checkout master 
    git merge better_branch    # fast-forward master up to the merge 
    
  5. 在本地工作。然而,當我試圖將我得到了以下內容:

     
    [email protected]**** /C/Users/NAME/Documents/GitHub/tabtrack (master) 
    $ git push 
    warning: push.default is unset; its implicit value is changing in 
    Git 2.0 from 'matching' to 'simple'. To squelch this message 
    and maintain the current behavior after the default changes, use: 
    
        git config --global push.default matching 
    
    To squelch this message and adopt the new behavior now, use: 
    
        git config --global push.default simple 
    
    See 'git help config' and search for 'push.default' for further information. 
    (the 'simple' mode was introduced in Git 1.7.11. Use the similar mode 
    'current' instead of 'simple' if you sometimes use older versions of Git) 
    Enter passphrase for key '/c/Users/NAME/.ssh/id_rsa': 
    To [email protected]:NAMEtaylor/tabtrack.git 
    ! [rejected]  master -> master (non-fast-forward) 
    error: unable to resolve reference refs/remotes/origin/bridge: No error 
    error: Cannot lock the ref 'refs/remotes/origin/bridge'. 
    error: failed to push some refs to '[email protected]:NAMEtaylor/tabtrack.git' 
    hint: Updates were rejected because the tip of your current branch is behind 
    hint: its remote counterpart. Integrate the remote changes (e.g. 
    hint: 'git pull ...') before pushing again. 
    hint: See the 'Note about fast-forwards' in 'git push --help' for details. 
    
     
    [email protected]**** /C/Users/NAME/Documents/GitHub/tabtrack (master) 
    $ git push origin master 
    Enter passphrase for key '/c/Users/NAME/.ssh/id_rsa': 
    To [email protected]:NAMEtaylor/tabtrack.git 
    ! [rejected]  master -> master (non-fast-forward) 
    error: failed to push some refs to '[email protected]:NAMEtaylor/tabtrack.git' 
    hint: Updates were rejected because the tip of your current branch is behind 
    hint: its remote counterpart. Integrate the remote changes (e.g. 
    hint: 'git pull ...') before pushing again. 
    hint: See the 'Note about fast-forwards' in 'git push --help' for details. 
    
     
    [email protected]**** /C/Users/NAME/Documents/GitHub/tabtrack (master) 
    $ git push origin bridge 
    Enter passphrase for key '/c/Users/NAME/.ssh/id_rsa': 
    error: unable to resolve reference refs/remotes/origin/bridge: No error 
    error: Cannot lock the ref 'refs/remotes/origin/bridge'. 
    Everything up-to-date 
    
  6. 我試圖git push -f但:

     
    [email protected]**** /C/Users/NAME/Documents/GitHub/tabtrack (bridge) 
    $ git checkout master 
    Switched to branch 'master' 
    
    [email protected]**** /C/Users/NAME/Documents/GitHub/tabtrack (master) 
    $ git push -f 
    warning: push.default is unset; its implicit value is changing in 
    Git 2.0 from 'matching' to 'simple'. To squelch this message 
    and maintain the current behavior after the default changes, use: 
    
        git config --global push.default matching 
    
    To squelch this message and adopt the new behavior now, use: 
    
        git config --global push.default simple 
    
    See 'git help config' and search for 'push.default' for further information. 
    (the 'simple' mode was introduced in Git 1.7.11. Use the similar mode 
    'current' instead of 'simple' if you sometimes use older versions of Git) 
    
    Enter passphrase for key '/c/Users/NAME/.ssh/id_rsa': 
    Counting objects: 13, done. 
    Delta compression using up to 2 threads. 
    Compressing objects: 100% (7/7), done. 
    Writing objects: 100% (7/7), 898 bytes | 0 bytes/s, done. 
    Total 7 (delta 5), reused 0 (delta 0) 
    To [email protected]:NAMEtaylor/tabtrack.git 
    
               
       
    • 1297c9f...bfa60d5 master -> master (forced update) error: unable to resolve reference refs/remotes/origin/bridge: No such file or d irectory error: Cannot lock the ref 'refs/remotes/origin/bridge'.
    [email protected]**** /C/Users/NAME/Documents/GitHub/tabtrack (master) $ git status On branch master nothing to commit, working directory clean
  7. 最後,我想git push origin bridge --verbose按照建議的一些stackoverflow問題:

     
    $ git push origin bridge --verbose 
    Pushing to [email protected]:ishaantaylor/tabtrack.git 
    Enter passphrase for key '/c/Users/Ishaan/.ssh/id_rsa': 
    To [email protected]:ishaantaylor/tabtrack.git 
    = [up to date]  bridge -> bridge 
    updating local tracking ref 'refs/remotes/origin/bridge' 
    error: unable to resolve reference refs/remotes/origin/bridge: No error 
    error: Cannot lock the ref 'refs/remotes/origin/bridge'. 
    Everything up-to-date 
    
  8. 我的git樹的屏幕截圖是通過點擊下面的鏈接顯示

(我需要更多的代表來發布功能PIC): http://i.imgur.com/FN9wHdi.jpg

請讓我知道如果我需要的任何其他信息在加問題變得更好。非常感謝您的時間,即使您只是閱讀我的問題!

回答

2

首先,設置默認推送策略:

git config --global push.default simple 

那麼你可以嘗試把你的主分支

git push -u -f origin master 

(你不應該需要你的橋支路,因爲你在合併的主它,併合並該分支回到主點4)

+1

非常感謝你的迴應! 「分支機構主設置爲從原點跟蹤遠程分支機構主機。所有內容都是[至今] 爲什麼這是解決方案,它是如何解決問題的? –

+0

@IshaanTaylor它允許您建立本地分支和遠程跟蹤之間的跟蹤關係,這意味着Git知道要推送什麼以及在哪裏推送。你可以在http://stackoverflow.com/a/17096880/6309看到更多 – VonC