git push failure没有冲突

Ste*_*her 5 git

我已经阅读了一些关于git push打破的解释,但似乎没有一个解决这个问题.

我无法将本地更改推送到远程存储库,即使在拉动并且没有冲突之后也是如此.

$ git pull
Already up-to-date

$ git st
# On branch unstable
nothing to commit (working directory clean)

$ git push
To ssh://<url>
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'ssh://<url>'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)

<url> 当然是我的存储库的真实URL.

拉动没有变化,没有冲突,我不确定还有什么可能导致失败.

我相信我已经正确设置了所有内容:

$ git remote -v
origin  ssh://<url> (fetch)
origin  ssh://<url> (push)

$ git branch -v
  master   175a09d [behind 18] openReview must now be called from thread other than main.
* unstable c9e5cab Progress on attachments.
Run Code Online (Sandbox Code Playgroud)

过去,我刚刚删除了我的本地存储库.但是,这种情况发生得更频繁.

  1. 是什么原因造成的?
  2. 我将来如何避免它呢?
  3. 我该如何解决这个问题?

小智 4

全面披露 - 我的 git 有点生疏,所以这可能不是 100% 正确。

看来您本地的“master”分支位于“origin”master 分支后面。当您运行“git Push”时,它将尝试使用相应的本地分支更新所有远程分支。要推送当前分支,请尝试git push origin unstable. 另外,如果您希望本地 master 分支保持最新状态,请签出 master 分支并运行git pull.