我昨天还能推,现在却推不动了。

当我使用git push origin master时,我得到一个错误:

$ git remote -v
origin  https://github.com/REDACTED.git (fetch)
origin  https://github.com/REDACTED.git (push)

$ git push origin master
Username for 'https://github.com': REDACTED
Password for 'https://REDACTED@github.com':
To https://github.com/REDACTED.git
! [rejected]         master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/REDACTED.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.

我的工作目录和远程存储库看起来像什么:


当前回答

git push -u origin main出错?试试这个解决方案。它将100%工作。

Git push origin master,改为Git push origin main

如何更换Main?

git分支-M main

其他回答

你需要给点力

用力推就行。

我也有同样的问题。我遇到这个问题是因为我没有做出任何承诺,甚至没有最初的承诺,但我仍然试图推动。

一旦我真的commit -m“your msg”,一切都很正常。

推送步骤:

git init
git add README.md      -------- or --------   git add .
git commit -m "first commit"
git remote add origin 'http github link'
git push -u origin main       ------ or -------    git push -f origin master

如果分支在main上,则:

git push -u origin main

对于主人:

git push -f origin master

对于Sourcetree用户

首先进行初始提交,或者确保没有任何未提交的更改。然后在Sourcetree的一侧有一个“REMOTES”。右键单击它,然后单击“推到原点”。好了。

Git错误:当本地存储库名称与相应的远程存储库名称匹配时,也会出现未能推一些引用。在将更改拉入远程存储库之前,请确保您正在使用正确的存储库对。

如果拼写错误,并且希望删除本地存储库,请执行以下步骤。

删除Windows上的本地存储库:

del /F /S /Q /A .git 删除目录. 更正本地文件夹名称(XXXX02->XXXX20),或者如果是新创建的repo,则删除它并重新创建repo (XXXX02 repo名称更改为XXXX20)。 git init 如果没有映射,则使用远程repo重新映射。 git remote add origin https://github.com/<username>/XXXX20.git . zip Git push -u origin master