git push -u origin master //会提示输入用户名和密码
输入完之后会出现以下错误:
Username for ‘https://github.com’: DylanLN
Password for ‘https://DylanLN@github.com’:
To https://github.com/DylanLN/oryxbot_ws-ros2
! [rejected] master -> master (non-fast-forward)
error: 无法推送一些引用到 ‘https://github.com/DylanLN/oryxbot_ws-ros2’
提示:更新被拒绝,因为您当前分支的最新提交落后于其对应的远程分支。
提示:再次推送前,先与远程变更合并(如 ‘git pull …’)。详见
提示:‘git push --help’ 中的 ‘Note about fast-forwards’ 小节。
然后输入
git fetch
git merge//会出现错误: fatel: 未指定提交并且 merge.defaultToUpstream 未设置。
此时需要重新git add ,git commit
然后执行
git push -u origin master
会出现以下错误:
! [rejected] master -> master (non-fast-forward)
error: 无法推送一些引用到 ‘https://github.com/xxxxx/xxx.git’
提示:更新被拒绝,因为您当前分支的最新提交落后于其对应的远程分支。
提示:再次推送前,先与远程变更合并(如 ‘git pull’)。详见
提示:‘git push --help’ 中的 ‘Note about fast-forwards’ 小节。
执行:
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
git pull
Merge made by the ‘recursive’ strategy.
README.md | 4 ++++
1 file changed, 4 insertions(+)
git add hello.txt
git commit -m "second push"
无文件要提交,干净的工作区
git push -u origin master
代码即可同步成功!