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

当我使用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 reset 
git remote -v
git pull --rebase
git init
git add -A
git commit -m "Add your commit"
git branch -M main
git push origin main --force

小心些而已。如果他们有一个自述文件,git重置删除他们。

其他回答

推送步骤:

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

Use

git push -f origin master

这个是写。

因为也许它没有什么可推的(真的,没有什么可推的)。这样做:

git remote add origin https://github.com/donhuvy/accounting133.git
git remote -v
git add .
git commit -m"upload"
git push --set-upstream origin master

在您的情况下更改远程存储库的URL。你可以跳过命令git remote -v,只是为了检查。

我也遇到过同样的问题,并通过以下步骤解决了它。

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"

如果您是第一次在GitHub页面上部署站点,只需运行这两个命令。

git commit -m "initial commit"
git push origin +HEAD