登录 主页

git push 报错 - 无法提交远程! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com……’

2024-02-05 06:31PM

参考:https://linlin.fun/blogs/124135651

在运行命令行里面git push的时候报错说:

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

解决方法:

1)在命令行直接使用这个命令:

meiyi@meiyi-Extensa-2511G:~/workspace/dongtaipaifang_2_backend$ git fetch origin master:tmp
Username for 'https://github.com': xxxxxx
Password for 'https://xxxxxx@github.com': 
From https://github.com/xxxxxx/dongtaipaifang_2_backend
 * [new branch]      master     -> tmp
2)如果出现报错不必理会,我这里是没有出现报错的
meiyi@meiyi-Extensa-2511G:~/workspace/dongtaipaifang_2_backend$ git rebase tmp
warning: skipped previously applied commit 82169b0
hint: use --reapply-cherry-picks to include skipped commits
hint: Disable this message with "git config advice.skippedCherryPicks false"
Successfully rebased and updated refs/heads/master.

3)继续输入命令即可

meiyi@meiyi-Extensa-2511G:~/workspace/dongtaipaifang_2_backend$ git push origin HEAD:master
Username for 'https://github.com': 347340
Password for 'https://347340@github.com': 
Everything up-to-date

4)然后使用 git log 就发现代码已经提交了

返回>>

登录

请登录后再发表评论。

评论列表:

目前还没有人发表评论