gpt4 book ai didi

git - merge 分支后推送时无法解析引用 refs/refs/remotes/origin/branch

转载 作者:太空狗 更新时间:2023-10-29 13:15:16 26 4
gpt4 key购买 nike

git 和 github 的新手。

我想在本地和远程用我的另一个分支 bridge 替换 git master 分支。问题是 git 无法解析 bridge 分支的引用。问题出在push到github上。

git树是怎么变成这样的:

  1. 通过 Git GUI 启动主分支。
  2. 继续,然后意识到它不是那么好并过渡到 Bash。
  3. 无法再推送到 github 以掌握,因为本地 master 分支的尖端落后于远程分支的尖端。
  4. 为了规避,我创建了另一个名为 bridge 的分支。我不喜欢将 bridge 设置为默认设置,因此我尝试使用以下方法将其改回 master:

    git checkout better_branchgit merge --strategy=ours master    # keep the content of this branch, but record a mergegit checkout mastergit merge better_branch             # fast-forward master up to the merge
  5. 它在本地有效。但是,当我尝试推送时,我得到了以下信息:

    NAME@**** /C/Users/NAME/Documents/GitHub/tabtrack (master)$ git pushwarning: push.default is unset; its implicit value is changing inGit 2.0 from 'matching' to 'simple'. To squelch this messageand maintain the current behavior after the default changes, use:  git config --global push.default matchingTo squelch this message and adopt the new behavior now, use:  git config --global push.default simpleSee '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 errorerror: 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 behindhint: 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 masterEnter 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 behindhint: 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 bridgeEnter passphrase for key '/c/Users/NAME/.ssh/id_rsa':error: unable to resolve reference refs/remotes/origin/bridge: No errorerror: Cannot lock the ref 'refs/remotes/origin/bridge'.Everything up-to-date
  6. 我尝试了 git push -f 但是:

    NAME@**** /C/Users/NAME/Documents/GitHub/tabtrack (bridge)$ git checkout masterSwitched to branch 'master'NAME@**** /C/Users/NAME/Documents/GitHub/tabtrack (master)$ git push -fwarning: push.default is unset; its implicit value is changing inGit 2.0 from 'matching' to 'simple'. To squelch this messageand maintain the current behavior after the default changes, use:  git config --global push.default matchingTo squelch this message and adopt the new behavior now, use:  git config --global push.default simpleSee '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
        
    • 1297c9f...bfa60d5 master -> master (forced update)error: unable to resolve reference refs/remotes/origin/bridge: No such file or directoryerror: Cannot lock the ref 'refs/remotes/origin/bridge'.
    NAME@**** /C/Users/NAME/Documents/GitHub/tabtrack (master)$ git statusOn branch masternothing to commit, working directory clean
  7. 最后,我根据一些 stackoverflow 问题的建议尝试 git push origin bridge --verbose:

    $ git push origin bridge --verbosePushing to git@github.com:ishaantaylor/tabtrack.gitEnter passphrase for key '/c/Users/Ishaan/.ssh/id_rsa':To git@github.com:ishaantaylor/tabtrack.git = [up to date]      bridge -> bridgeupdating local tracking ref 'refs/remotes/origin/bridge'error: unable to resolve reference refs/remotes/origin/bridge: No errorerror: Cannot lock the ref 'refs/remotes/origin/bridge'.Everything up-to-date

单击下面的链接可显示我的 git 树的屏幕截图(我需要更多代表才能发布正常运行的图片): http://i.imgur.com/FN9wHdi.jpg

如果我需要在问题中添加任何其他信息以使其变得更好,请告诉我。非常感谢您抽出宝贵时间,即使您刚刚阅读了我的问题!

最佳答案

首先,设置默认推送策略:

git config --global push.default simple

然后你可以尝试推送你的master分支

git push -u -f origin master

(你不应该需要你的 bridge 分支,因为你在其中 merge 了 master,并在第 4 点将该分支 merge 回 master)

关于git - merge 分支后推送时无法解析引用 refs/refs/remotes/origin/branch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22007503/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com