gpt4 book ai didi

Git 推送提示非快进,即使远程已被 pull 出

转载 作者:太空狗 更新时间:2023-10-29 13:31:05 28 4
gpt4 key购买 nike

我正在尝试将我的更改推送到 NAS 上的存储库。它以我无法理解的方式失败。

documentation声明默认情况下 push 仅适用于快进更新。很公平。所以我做了一个 git pull(我的 Remote 叫做 rubix):

D:\RoboCup\Dev\TinMan>git pull rubix masterFrom ssh://rubix/volume1/git/TinMan * branch            master     -> FETCH_HEADAlready up-to-date.

一切看起来都很好。让我们尝试 push ...

D:\RoboCup\Dev\TinMan>git push rubix masterTo ssh://dnoakes@rubix/volume1/git/TinMan ! [rejected]        master -> master (non-fast-forward)error: failed to push some refs to 'ssh://dnoakes@rubix/volume1/git/TinMan'To prevent you from losing history, non-fast-forward updates were rejectedMerge the remote changes before pushing again.  See the 'Note aboutfast-forwards' section of 'git push --help' for details.

我已经通读了关于 git push 的文档,但此时我不明白为什么我会看到这个问题。

这是一些其他的上下文信息:

D:\RoboCup\Dev\TinMan>git --versiongit version 1.7.0.2.msysgit.0D:\RoboCup\Dev\TinMan>git branch* (no branch)  master

最后一行看起来很可疑。我怎么能不在任何分支?另请注意,我还有一些未跟踪的文件和已修改(未暂存)的更改。

如有任何帮助,我们将不胜感激。谢谢。

最佳答案

这是一种同步的方法。

首先,提交任何更改,然后使用 git log 记录您想要推送的任何提交。

接下来像这样重置你的主机以匹配 Remote :

git checkout master
git reset --hard remotes/rubix/master

最后,挑选你想要保留的提交

例子:

git cherry-pick 111aaa111
git cherry-pick 123abc123

现在推送应该起作用了。

git push rubix master

关于Git 推送提示非快进,即使远程已被 pull 出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5723714/

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