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

当我使用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 init Git添加。 git commit -m '添加提交信息' git远程添加origin https://User_name@bitbucket.org/User_name/sample.git (上面的URL, https://User_name@bitbucket.org/User_name/sample.git,指的是你的Bitbucket项目的URL) Git push -u origin master

Hint

检查你的GitHub账户是否连接到你的本地Git存储库:

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

其他回答

在使用该命令时,我也遇到过这个问题。

Git push -u origin main

所以我使用npm cache clean——force清除了npm的所有缓存,并尝试再次push。这对我来说很有效。

你的宣传和你的故事有关吗。如果是,检查jira的工作流程状况。 管理员可以根据某些工作流程配置为只允许推送。

记得在推送到GitHub存储库之前提交您的更改。这可能会解决你的问题。

在推送之前未提交初始更改也会导致问题。

最好使用rm -rf .git/hooks,然后尝试git push