git和github新手。
我想在本地和远程替换我的其他分支master
的git bridge
分支。问题是git无法解析bridge
分支的引用。问题来自推向github。
git树如何成为这样:
为了规避,我创建了另一个名为bridge的分支。我不喜欢我将桥接器设为默认设置,因此我尝试使用以下命令将其更改为主设备:
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
它在本地工作。但是,当我试图推动时,我得到了以下内容:
NAME@**** /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 git@github.com: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 'git@github.com: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.
NAME@**** /C/Users/NAME/Documents/GitHub/tabtrack (master) $ git push origin master Enter passphrase for key '/c/Users/NAME/.ssh/id_rsa': To git@github.com:NAMEtaylor/tabtrack.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'git@github.com: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.
NAME@**** /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
我尝试git push -f
但是:
NAME@**** /C/Users/NAME/Documents/GitHub/tabtrack (bridge) $ git checkout master Switched to branch 'master' NAME@**** /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 git@github.com:NAMEtaylor/tabtrack.git
最后,我根据有关stackoverflow问题的建议尝试git push origin bridge --verbose
:
$ git push origin bridge --verbose Pushing to git@github.com:ishaantaylor/tabtrack.git Enter passphrase for key '/c/Users/Ishaan/.ssh/id_rsa': To git@github.com: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
点击下面的链接显示我的git树的屏幕截图(我需要更多代表来发布功能图片): http://i.imgur.com/FN9wHdi.jpg
如果我需要在问题中添加任何其他信息以便它变得更好,请告诉我。非常感谢您的时间,即使您刚刚阅读了我的问题!
答案 0 :(得分:2)
首先,设置默认推送策略:
git config --global push.default simple
然后你可以尝试推动你的主分支
git push -u -f origin master
(你不应该需要你的桥分支,因为你在其中合并了master,并在第4点将该分支合并回master)