Git提交被拒绝
使用idea提交代码时,出现Push rejected: Push to branchname was rejected,看到这样的提示通常是账号权限不够不允许提交,但是权限不够并不是造成我此次无法提交的原因。
问题结论:本地有分支,远端没有,无法通过开发工具自动创建
解决办法:
1.找到项目工作空间,打开git bash(在IDEA 中terminal窗口亦可)
2.在窗口用命令 git push 进行提交时,会提示
fatal: The current branch XX has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin XX
大概意思就是:当前分支 XX 没有上游分支,要推送当前分支并将远程设置为上游,请使用 git push --set-upstream origin XX
3.可以按照提示进行操作,也可使用其他命令操作
1.git push origin src:dest //将本地分支推动到远程,并已dest命名(将src,dest替换为自己的分支名)
2.git push -u origin barnchName //barnchName 替换为自己的分支名,-u == --set-upstream
4.执行成功