问题
在使用git
向github
上提交项目时遇到下面的问题:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/BXCQ/XuanSecret.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. If you want to integrate the remote changes,
hint: use 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解决方案1
原来使用的提交命令是git push -u origin 分支名
不妨尝试一下使用覆盖提交的方式,这个对第一次提交有用。
git push -f origin 分支名
其中“-f”是覆盖提交的参数。
解决方案2
看报错第三行
意思是让我们在推之前先拉一次
- 拉代码:
git pull
- 推代码:
git push
这样问题就可以解决了。