idea中新建git分支,并提交到远程github

一、IDEA连接github,创建本地仓库和远程github仓库

1. idea登录github ,参考:使用IntelliJ IDEA如何连接Github并上传项目

2. idea创建本地仓库,连接github远程仓库。参考:idea中将项目与github关联

二、IDEA中创建本地分支,并提交到远程仓库分支中

1. IDEA中创建本地分支。参考:IDEA本地新建分支并push到远程创建分支

2. 当将本地分支提交到远程分支是出现提交被拒绝错误“Push rejected Push to origin/dev-01 was rejected”。

参考:Git错误信息解决办法:Push rejected: Push to origin/platformDev was rejected

 

 大概步骤:在idea中的Terminal中进入到提交项目中,依次输入一下命令。注:dev-01是我新建分支的名字。完成步骤后再次push一下,可能需要merge一下

E:\hahaha\study-cloud>git checkout -b dev-01
fatal: A branch named 'dev-01' already exists.

E:\hahaha\study-cloud>git branch -aa
* dev-01
  master
  remotes/origin/dev-01
  remotes/origin/master

E:\hahaha\study-cloud>git branch --set-upstream-to origin/dev-01 dev-01
Branch 'dev-01' set up to track remote branch 'dev-01' from 'origin'.

  

 3. 如果出现一下问题一般是网络问题,重现连接其他网络试试。

Push failed
            Invocation failed Server returned invalid Response.
            java.lang.RuntimeException: Invocation failed Server returned invalid Response.
            at org.jetbrains.git4idea.http.GitAskPassXmlRpcClient.askUsername(GitAskPassXmlRpcClient.java:50)
            at org.jetbrains.git4idea.http.GitAskPassApp.main(GitAskPassApp.java:64)
            Caused by: java.io.IOException: Server returned invalid Response.
            at org.apache.xmlrpc.LiteXmlRpcTransport.sendRequest(LiteXmlRpcTransport.java:242)
            at org.apache.xmlrpc.LiteXmlRpcTransport.sendXmlRpc(LiteXmlRpcTransport.java:90)
            at org.apache.xmlrpc.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:72)
            at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:194)
            at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:185)
            at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:178)
            at org.jetbrains.git4idea.http.GitAskPassXmlRpcClient.askUsername(GitAskPassXmlRpcClient.java:47)
            ... 1 more
            remote: No anonymous write access.

  三、idea中连接开源的git项目,在本地修改上传到开源github中

1. 先用git 命令从远程仓库克隆下项目代码到本地的文件夹

2. 在文件夹中用idea打开该项目,检查版本控制Remote中有没有加入该项目的git地址,检查方式:VCS>Git>Remotes,打开后检查有没有gi的url地址信息,如果没有,点加号,添加项目的git地址,以及名称,名称随意填一个即可。

 

3.最后选择代码,commit,push....。也可在左下角的Git控制栏中检查设置相关的git信息,可以在这里切换多个远程分支。

 4.  idea中设置多个远程remote仓库,以及git的使用

参考:

IDEA中一个工程多个模块(module)分别提交到不同的git服务器

Idea中关于Git的使用

详解IDEA中的Git操作

IDEA上Git操作

posted @ 2020-11-12 20:20  樟樟22  阅读(7035)  评论(0编辑  收藏  举报